A Web service is software that provides platform-independent access to its data to other software products over the Internet using XML and standards such as SOAP, WSDL, and UDDI.
What can Web services be used for in practice? Imagine a stock exchange whose servers have full information about the current quotes of all securities traded on this exchange. This is very important information, online access to which can be very valuable and useful for remote software systems. Or another example that is closer to the common man: a weather bureau server can contain information about weather conditions in a certain region or on the entire planet. This information may also be used by third party applications.
Many people have often seen weather site informers, but this is not the most convenient method for obtaining real information for corporate applications, as it limits the ability to operate on the information received. There are only two things you can do with such an informer: "hang" it on your site or remove it from the site if it is already posted there. But what about applications that need to receive the raw data f of the weather bureau server and process it to perform some complex operations (for example, to graphically simulate maps with corresponding temperatures applied to regions)?
To solve such problems, a stock exchange server or weather bureau can become a provider (supplier) of Web services, and applications that receive data from them via the Internet can become consumers of this data. Thus, a client-server architecture is formed, where the data provider is the server, and the consumer is the client, while the server and client software do not have to be compatible, the main condition is the support of Web services.
The exchange between the server and the client is carried out using standard Internet protocols, such as, for example, HTTP. A web service describes itself and defines an API for interacting with it. at the same time, the elements of this API are automatically converted into language constructs for the programming language that the client application uses. Web services are described according to the WSDL (Web Services Description Language) specification. The transfer of the data itself from the server to the client is done in the SOAP (Simple Object Access Protocol) format.
In other words, the client application accesses the WSDL file by its URL, i.e. the usual GET method. At the same time, it receives a description of the methods of the Web service and can then use them as its own (that is, without writing additional code on the client side - the Web service becomes, as it were, a remote continuation of the client program).
Based on the web service architecture, we create the following two components as part of the web services implementation:
Service provider or publisherThis is a web service provider. The service provider implements this service and makes it available on the Internet or intranet. We will be writing and publishing a simple web service using the .NET SDK.
Service provider or consumerThis is any consumer of the web service. The requester consumes an existing web service by opening network connection and sending an XML request. We will also write two requests for web services: one web consumer (ASP.NET application) and another consumer based on Windows applications.
Below is our first example of a web service that runs as a service provider and exposes two methods (add and SayHello) as web services to be used by applications. This is the standard template for a web service. .NET services use the .asmx extension. Note that a method exposed as a web service has a WebMethod attribute. Save this file as FirstService.asmx in the IIS virtual directory (as described in the IIS setup, e.g. c:\MyWebSerces).
FirstService.asmxusing System; using System.Web.Services; using System.Xml.Serialization; public class FirstService: WebService ( public int Add(int a, int b) ( return a + b; ) public String SayHello() ( return "Hello World"; ) )
To test a web service, it must be published. A web service can be published either on an intranet or on the Internet. We will publish this web service to IIS running on the local machine. Let's start by setting up IIS.
- Open Start → Settings → Control Panel → Administrative Tools → Internet Services Manager.
- Expand and right-click Default Web Site; select New → Virtual Directory. The Virtual Directory Creation Wizard opens. Click "Next.
- The Virtual Directory screen appears. Enter a name for the virtual directory. For example, MyWebServices. and click Next.
- The "Web Content Directory" screen opens.
- Enter a directory name for the virtual directory. For example, c:\MyWebServices Click Next.
- The Access Permission screen appears. Change the settings according to your requirements. Let's keep the default settings for this exercise.
- Click "Next". It completes the IIS setup.
- Click "Finish" to complete the setup.
To check if IIS is configured correctly, copy the HTML file (for example x.html) to the virtual directory (C:\MyWebServices) created above. Now open Internet Explorer and enter http://localhost/MyWebServices/x.html. It should open the x.html file.
Note. If that doesn't work, try replacing localhost with your device's IP address. If it still doesn't work, check if IIS is running; you may need to reconfigure IIS and the virtual directory.
To test this web service, copy FirstService.asmx to the IIS virtual directory created above (C:\MyWebServices). Open the web service in Internet Explorer (http://localhost/MyWebServices/FirstService.asmx). It should open the web service page. The page should have links to two methods that we provide as web services to our application. Congratulations! You have written your first web service!
Web service testingAs we have just seen, it is easy to write web services in the .NET Framework. Writing web services is also easy in the .NET environment; however, it is slightly more active. As discussed earlier, we will be writing two types of service consumers: one is a website and the other is a user based Windows application. Let's write our first web service consumer.
Web servicesWrite a web consumer as given below. Name it WebApp.aspx. Note that this is an ASP.NET application. Save this in the web service virtual directory (c:\MyWebServices\WebApp.axpx). This app has two text fields that are used to get numbers from the user to add. It has one "Run" button that, when clicked, gets the Add and SayHello web services.
WebApp.axpxvoid runSrvice_Click(Object sender, EventArgs e)( FirstService mySvc = new FirstService(); Label1.Text = mySvc.SayHello(); Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text), Int32.Parse(txtNum2 .Text)).ToString(); )
First Number to Add : 4< /asp:TextBox>
Second Number To Add : 5
Web Service Result -
Hello World Service : Label< /asp:Label>
Add Service : & Label
After creating the consumer, we need to create a proxy to consume the web service. This work is done automatically by Visual Studio .NET for us when we refer to the added web service. Here are the steps to follow:
- Create a proxy to use the web service. The proxy is created using the WSDL utility provided with the .NET SDK. This utility retrieves information from a web service and creates a proxy. The proxy server is only valid for a specific web service. If you need to use other web services, you also need to create a proxy for that service. Visual Studio .NET automatically creates a proxy when a web service reference is added. Create a proxy for the web service using the WSDL utility provided with the .NET SDK. It will create a FirstSevice.cs file in the current directory. We need to compile it to generate the FirstService.dll (proxy) for the web service.
- c:>WSDL http://localhost/MyWebServices/FirstService.asmx?WSDL
- c:> csc /t:library FirstService.cs
- Place the compiled proxy in the bin directory of the web service virtual directory (c:\MyWebServices\bin). Internet Information Services (IIS) looks for a proxy server in this directory.
- Create a service consumer just like we did. Note that the web service proxy object is created on the consumer. This proxy takes care of interacting with the service.
- Enter the consumer URL in IE to test it (for example, http://localhost/MyWebServices/WebApp.aspx).
Writing a web service application based on Windows applications is similar to writing any other Windows application. You only need to create a proxy (which we have already done) and refer to this proxy when compiling the application. Below is our windows application The that uses the web service. This application creates a web service object (a proxy, of course) and calls the SayHello and Add methods on it.
WinApp.csusing System; using System.IO; namespace SvcConsumer ( class SvcEater ( public static void Main(String args) ( FirstService mySvc = new FirstService(); Console.WriteLine("Calling Hello World Service: " + mySvc.SayHello()); Console.WriteLine("Calling Add( 2, 3) Service: " + mySvc.Add(2, 3).ToString()); ) ) )
Compile it with c: \> csc /r:FirstService.dll WinApp.cs . It will create a WinApp.exe file. Run it to test the application and web service.
Now the question is: how can you be sure that this application is actually calling a web service?
It's easy to check. Stop your web server so that the web service cannot be contacted. Now launch the WinApp application. It will throw an exception at runtime. Now start the web server again. He must work.
Today, WEB services are used almost everywhere - they provide us with information about flights of planes and trains, exchange rates and weather. It is not surprising that 1C also has the ability to create its own WEB services, allowing you to act as both a supplier and a consumer. This mechanism is built into the 1C:Enterprise 8.3 platform, and developers can even add their own objects of the WEB services type to the standard configuration. Their architecture is built on a set of services that allow you to exchange information with other software.
Creation of a web service 1COne of the main advantages of 1C WEB services is the absence of the need to provide direct access to information security data. A properly configured 1C web service allows other applications to use functions from outside. In such cases, the function itself should determine the right to use data according to the specified parameters according to the rules prescribed by the developer.
How to create a web service in 1C?In order for a certain function of the 1C system to become available to external software, you must perform the following algorithm of actions:
- SSL/TLS
- WS-I BP
To most clearly demonstrate the operation of the WEB services mechanism, let's create an example - a functional that determines the length of the entered string. Software will pass a string as a query parameter, and the function described in 1C will return the number of characters. When creating, you need to remember that the publication of this mechanism will make it possible for various software to access it. Since not every software is capable of perceiving Cyrillic, we will name configuration objects using Latin characters.
Open the configurator, find the "WEB services" branch in the tree and add a new service "wa_LengthString". You also need to add a new operation on the "Operations" tab. Let's call it "CalcLengthString", in the properties we specify the type of the returned value - int or integer and create an "InputString" parameter inside it. Leave the value type as string.
Now it is necessary to register the action of the CalcLengthString function in the WEB service module. To do this, open the properties of the created function and press the button in the form of a magnifying glass on the right, next to the "Procedure name" input field. 1C will automatically create a function in our WEB service module and open it so that we can describe the CalcLengthString action. Let's take advantage of this and write the action of the function - determining the length of the input string.
In fact, this completes the creation of the simplest WEB service. Now you need to “put” this service into the public domain so that third-party software or other 1C systems can use this functionality.
In order for us to be able to publish the created web service with its functionality, we need to have access to the site. Before we start publishing the service, we need to check the filename in the properties of the generated wa_LengthString module. It should be clear, simple and have the extension "1cws".
Now it's time to publish the WEB service we created on the server. This feature appeared in version 8.3 of the platform, and many companies have already realized the full benefit of this functionality. In order to start publishing, you need to open the “Administration/Publishing on a web server…” form in the configurator.
In the window that opens, we need to set up 1C Web services and fill in certain fields:
- Name. Indicates a folder on the web server where the description of our web service will be stored. Be careful about case, as servers sometimes distinguish between uppercase and lowercase characters;
- Web server. You must select a server from those installed on the computer;
- Catalog. You must select the path to the folder where the web server data for setting up the connection is stored. Only Latin letters are used;
- Two features of the "Boolean" type. The first one is useful to us if we need to configure access through the web client to the configuration. In order to publish a 1C service, you must put a second mark.
It remains only to check that the desired WEB service has a checkbox in the first column, and click on "Publish".
Since this mechanism is still quite new, you may encounter an error like "Error while performing file operation ...". In this case, you just need to repeat the "Publish" button. In most cases, this helps, and you will see a message that the web service publication is complete.
en//ws/.1cws?wsdl
In response to such an address request, the browser must display the structure of the XML file. If you see a blank page, an error, or strange characters (coding problems), then you need to check all the steps again. It's also a good idea to make sure the server is set up correctly and you have access to it. After successful publication of the 1C WEB service, third-party applications will be able to use it.
Web services are one of the platform mechanisms used for integration with other information systems. It is a means of supporting SOA (Service-Oriented Architecture) - service-oriented architecture, which is the modern standard for integrating applications and information systems.
A significant advantage of service - oriented architecture is that it allows you to develop the infrastructure of the enterprise in a homogeneous way, without destroying existing solutions. Its use allows you to minimize costs by integrating heterogeneous and legacy systems into the modern enterprise landscape. It allows the implementation of loosely coupled software components in order to maximize their reusability.
Service-oriented architecture is being actively developed and supported by large vendors. It is built on the basis of services, autonomous or managed from the outside. Web services are the preferred way to implement them. They are platform independent, self-contained and universally supported.
Application solution 1C:Enterprise 8 can be both a provider of web services and a consumer of web services published by other providers.
Systems using arbitrary hardware and software platforms can act as consumers. Web services technology is platform independent.
Technical implementation of web services
If the application solution is a web service provider, then both in the file and in the client-server operation, the interaction between the application solution and the web service consumers is carried out through the web server, using the web server extension module.
In this case, when the consumer accesses the application solution web service, the web service module is executed. This module is contained in the configuration and it contains procedures that are performed when calling certain operations of the web service.
In the case of a client-server operation, this module will be executed in a cluster. In the case of the file version of work - in the web server extension module.
If the application solution is a consumer of a third-party web service, then the interaction between the application solution and the web service provider is performed by the client application. It calls certain operations of the web service and processes the received data.
The 1C:Enterprise platform acting as a web service consumer supports optimized transfer of binary data via the MTOM protocol. MTOM mode is enabled in 1C:Enterprise automatically.
We have selected the top 10 web services, the reviews of which were published in Lifehacker last year. These tools help us organize time effectively and work in a team, manage our business, acquire new knowledge and develop our abilities, and enjoy more leisure and entertainment. Try them in the new year and let your life become brighter and more comfortable!
The ingenious ifttt mashup allows you to establish a causal relationship between events in various web services according to the principle “If This happened in one service, then That happen in another service. More than 20 services, social networks and technologies are supported: Gmail and any other mail, RSS, Facebook, Twitter, Evernote, Dropbox, Google Reader, Google Talk, Foursquare, Flickr, Instapaper, ReadItLater, LinkedIn, YouTube and others. In addition, SMS, phone calls, changes in stock prices and even weather changes in a given region serve as events. Examples of automated processes created with ifttt: “if a post is marked with an asterisk in Google Reader, then it is saved in Evernote”, “if it starts to rain in New York, then an SMS notification is received”. Now imagine the possibilities of ifttt in the future "internet of things", when different electronic devices will be able to communicate with each other! ;) I first learned about this service from a friend of "Lifehacker" Viktor Zakharchenko. Later, he also talked about his experience with ifttt in a solo episode of the 42 podcast about productivity and startup management.
Bookmate is your personal electronic library, books from which you can read on your computer and mobile devices(iPhone, iPad, Android, Symbian). At the same time, data is synchronized between the devices you use - having started reading on a computer, you can continue it on a smartphone or tablet from where you left off. The Bookmate fund contains several thousand free books, many books are available by subscription at a cost of only 99 rubles per month. If you don't find the book you need among them, you can upload it to the library yourself. The service allows you to share recommendations with friends, see their reading lists and borrow books from their bookshelves. For lovers of reading, I can also recommend the wonderful social network of book lovers Goodreads, which I myself have been using for almost a year and which we talked about in the 40th episode of the 42 podcast together with Petr Didenko and Viktor Zakharchenko.
Modern companies must use new technologies to increase their competitiveness and stimulate their development. Many accounting and business management tasks can be outsourced, and in many cases it is convenient for an individual entrepreneur or LLC to use cloud services such as My Business. This service is a profitable replacement for the usual outsourcing. With its help, you can semi-automatically maintain accounting records, calculate taxes, submit reports to government agencies electronically via the Internet, receive expert advice, create a package of documents necessary for registering an individual entrepreneur in 15 minutes (and soon it will be possible to prepare documents and to register an LLC). Also pay attention to a similar service from the SKB Kontur company - Elba electronic accountant. If you are interested in the topic of cloud technologies for business, then listen to the 54th episode of the 42 podcast featuring Petr Didenko and Nina Gorbunova.
Another important category of cloud services is project management systems. One of the best (and free) is TeamLab, a worthy competitor to Basecamp and other popular systems. TeamLab comes in three solutions - as a SaaS for use in a browser immediately after registering an account; in the form of an open source code that you can independently modify to suit your needs and tastes, in order to then deploy the system on your servers; and in the form virtual machine with a pre-installed TeamLab portal on Amazon servers. TeamLab includes modules for project management, collaboration, document management, calendar, CRM-system (customer relationship management system). TeamLab Marketing Manager Nina Gorbunova presented this system in the 54th episode of the 42 podcast about cloud technologies for business.
The new trendy Pinterest service allows you to create beautiful virtual boards with images of various objects, buildings, places, interiors, dishes - everything that you love and want to show others. New objects are added to the boards very simply - using the bookmarklet for browsers or manually through the web interface. On Pinterest, you can keep up to date with your friends' virtual boards, looking at interesting pictures for ideas, inspiration, and just a good mood. As an example, here is my board "Guests of the 42 Podcast" with photos of all the wonderful guests, information about their activities and links to episodes of the podcast with their participation.
With the help of the Yast time tracking service, you can track the time spent on various projects and individual tasks, find weak spots in your work schedule and optimize them. The service is designed for both individual users and small teams. The time counter when performing a task starts and stops with one click, and later you get detailed reports in different sections. Time trackers are very useful time management tools - just as important as task managers and calendars. I know from experience that personal effectiveness can be drastically improved by taking a deep look at your work schedule and taking a little time to optimize it.
Moredays is an online organizer stylized as paper planners and somewhat reminiscent of the legendary Moleskins. Its main advantage is its amazing beauty. The designers did their best and made one of the most beautiful organizers in the world. At the same time, Moredays has a fairly rich functionality: you can manage tasks, schedule time in your calendar, store notes, contacts, share individual organizer pages with other people via Twitter, Facebook and Google+, synchronize data with Evernote and Google Apps, and soon there will be mobile clients.
If you are one of the founders of Facebook, then any of your projects instantly becomes known. And so it happened with the Asana project management system by Dustin Moskowitz, co-founder of the world's largest social network. However, Asana deserves attention not only because of Dustin's personality - the developers have created a simple and convenient service with a pleasant but strict interface. Asana is suitable for individual use and for working in a small team. The functionality of the system can hardly be called rich, but perhaps this is precisely one of its main advantages for those who do not need project management tools overloaded with functions. Asana syncs with Google Calendar, Apple iCal and Microsoft Outlook, integrates with mail, has clients for smartphones and tablets.
BO.LT provides a simple yet amazing opportunity to edit any web page to your liking. It is enough to specify its address and you can very easily, without knowledge of HTML and other web development technologies, make any changes to the text and design of a copy of this web page, and then send other people a shortened link to the result. Friends or colleagues invited to view can also edit this web page. Service is indispensable when it is required to clearly present appearance site after various improvements, brainstorm new design ideas, or show your friends a web page with your explanatory comments. You can switch to HTML editing mode for even more freedom of action.
Dear readers, what web services did you like in 2011? Which of them can you recommend to us for reviews in Lifehacker?