Talk about WebServices (partial turn)

Source: Internet
Author: User
Tags soap client stock prices wsdl

1.1. Basic concept of WEB service


Web service, also known as XML Web service WebService, is a lightweight, independent communication technology that can receive requests passed from the Internet or other systems on the intranet. is: Software services provided through SOAP on the web, described using WSDL files, and registered through UDDI.

XML: (extensible Markup Language) Extensible Markup Language. Temporary data processing for short-term, web-oriented network, is the basis of soap.

Soap: Simple Object access Protocol protocol. is the communication protocol for XML WEB Service. When a user finds your WSDL description document through UDDI, he can invoke one or more of the actions in the Web service that you set up by soap. SOAP is a specification for calling methods in the form of XML documents that can support different underlying interfaces, such as HTTP (S) or SMTP.

WSDL: (Web Services Description Language) A WSDL file is an XML document that describes a set of SOAP messages and how to exchange them. In most cases, it is automatically generated and used by the software.

UDDI (Universal Description, Discovery, and integration) is a new project primarily for Web service providers and users. Before a user can invoke a Web service, it is important to determine which business methods are included in the service, to find the called interface definition, and to prepare the software on the server side, and UDDI is a mechanism to guide the system through the description document to find the appropriate service. UDDI uses the SOAP message mechanism (standard xml/http) to publish, edit, browse, and find registration information. It uses XML format to encapsulate various types of data and send it to the registry or to the registry to return the required data.

1.2. Characteristics of XML Web service

The primary goal of WEB service is interoperability across platforms. To achieve this goal, Web Service is based entirely on platform-independent, software-vendor-specific standards, such as XML (Extensible Markup Language), XSD (XML Schema), and is a new platform for creating interoperable, distributed applications. So using Web service has many advantages:

1. Cross-firewall communication

If the application has thousands of users and is distributed around the world, then communication between the client and the server will be a tricky issue. Because there is usually a firewall or proxy server between the client and the server. The traditional approach is to use a browser as a client, write down a lot of ASP pages, and expose the middle tier of the application to the end user. The result is that the development is difficult and the program is difficult to maintain. If client code is no longer so dependent on HTML forms, the client's programming is much simpler. If the middle-tier component is replaced with a Web service, the middle-tier component can be called directly from the user interface, eliminating the step of building an ASP page. To invoke a Web Service, you can directly use a SOAP client such as Microsoft SOAP Toolkit or. NET, or you can use your own SOAP client and then connect it to your application. It not only shortens the development cycle, but also reduces the complexity of the code and improves the maintainability of the application. At the same time, the application no longer needs to jump to the corresponding results page each time the middle-tier component is called.

2. Application integration

Enterprise-Class application developers know that it is common for businesses to integrate various programs that are written in different languages and run on different platforms, and that this integration will take a lot of development power. Applications often need to get data from programs running on one host, or send data to a host or other platform application. Even on the same platform, a variety of software produced by different software vendors often need to be integrated. With Web Service, applications can "expose" functionality and data in a standard way for use by other applications.

XML WEB Services provides the ability to exchange messages using standard protocols (HTTP, XML, SOAP, and WSDL) in a loosely coupled environment. Messages can be structured, typed, or loosely defined.

3, business-to-business integration

Business-to-business-to-business,as in businesses doing businesses with other businesses, businesses (generally referred to enterprises) of business e-commerce, that is, between enterprises and enterprises through the Internet products, Exchange of services and information. Popular parlance refers to the trade between the supply and demand of e-commerce business (or enterprises, companies), they use the Internet technology or a variety of business network platform to complete the process of business transactions.

Web Service is the key to the success of business-to-business integration. With Web service, companies can simply "expose" critical business applications to designated suppliers and customers, and Web service runs on the internet and can be easily implemented anywhere in the world, with relatively low operating costs. Web service is just a key part of business-to-business integration, and many other parts are needed to achieve integration. The greatest benefit of using Web service for business-to-business integration is the ease of interoperability. As long as the business logic is "exposed" and becomes a Web Service, it is possible for any designated partner to invoke these business logic, regardless of the platform on which their system runs, and what language to use. This greatly reduces the time and cost of spending on business-to-business integration.

4. Software and data reuse

Web Service can reuse the data behind the code while allowing reuse of the code. With Web service, it is no longer necessary to purchase, install, and invoke these components from a third party, just call the remote Web service directly, as you did before. Another kind of software reuse is the integration of the functions of several applications, through the Web Service "exposed", it is very easy to integrate all these features into your portal site, to provide users with a unified, user-friendly interface. You can use the functionality provided by a third-party Web service in your application, or you can make your own application functionality available to others through a Web service. In both cases, the data behind the code and the code can be reused.

As you can see from the above discussion, Web Service is most useful when it is interoperable or remotely invoked over the Web. However, there are cases where Web service does not bring any benefit at all, and Web service has some drawbacks:

1. Stand-alone application

Today, businesses and individuals are also using many desktop applications. Some of them only need to communicate with other programs on this computer. In this case, it is best not to use the Web Service, as long as the local API. COM is well suited to working in this situation because it is both small and fast. This is also true for server software running on the same server. Of course, Web Service can also be used in these situations, but that not only consumes too much, but does not bring any benefits.

2. Some applications of LAN

In many applications, all programs use COM under the Windows platform, all running on the same LAN. In these programs, using DCOM is much more effective than soap/http. Similarly, if a. NET program is to connect to another. NET program on the local area network, you should use. NET Remoting. In fact, in. NET remoting, you can also specify that you use Soap/http to make Web Service calls. However, it is best to make RPC calls directly over TCP, which is much more effective.

1.3. Application of XML Web service

1. The initial XML Web Service is often a source of information that can easily be incorporated into the application, such as stock prices, weather forecasts, sports scores, and so on.

2. Provide existing applications as XML Web service to build new, more powerful applications and take advantage of XML Web service as building blocks.

For example, a user can develop a sourcing application to automatically obtain price information from different vendors, so that users can select suppliers, submit orders, and then track the shipment of the goods until they receive the goods. In addition to providing services on the Web, the vendor's application can also use an XML Web service to check the customer's credit, collect the purchase price, and handle shipping formalities with the shipping company.

Second, WEB service development

The. NET platform has built-in support for Web service, including the building and use of Web service. Unlike other development platforms, using the. NET platform, you do not need other tools or SDKs to complete the development of Web service. The. NET Framework itself fully supports Web service, Includes server-side request handlers and support for sending and receiving SOAP messages to clients. We'll step through it. Create and use a simple Web Service using Microsoft Visual Studio. NET 2010 (hereafter referred to as Vs.net 2010).

First, open the VS2010, open "file-new-site", select "ASP. NET Web Service", and if not, change the framework to the 3.5,4.0 without this, click OK, complete the build service (called: Service a).

Next open the Service.cs file under App_Code, you can see that a method of HelloWorld () is written by default, and we can write our own method in reference to its format. Can be invoked on the client after being referenced by the service.

1 " Method Description " )]2publicvoid  webmethod_name (parameter)3{4       // method Body 5 }

The next step is to invoke this "network Service" in the project (said: Project B) in the reference, here we call the service created above as a network service, because it and we are located in the client can be on different networks. We start service A, and then add the service reference in Project B, if it is a local service, we can drop down the Address bar list, the service a will appear, click "Go", the following "service" box will show the details of service A, OK; if it is a service on the Web, we click "Advanced"-" Add Web Reference (W) ... "Enter the URL and change the Web reference name to determine it."
Finally, you can use the System library function as a pretext to make references. Using namespace, then use.

Because this belongs to the service reference, we need to start the WebService Program (service a). ----Server did not start you also want to access the server!

Talk about WebServices (partial turn)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.