Typical web service structure

Source: Internet
Author: User

No matter what tool or language your Web Service uses, the overall structure should be shown as long as you call it through HTTP using the SOAP protocol. Generally, you use your preferred language (such as VB 6 or VB. to build your web service, and then use the soap toolkit or. net built-in support to expose it to Web customers. Therefore, customers in any language and platform can read its WSDL document to call this web service. The customer generates a SOAP request message based on the WSDL description. Web services are placed after Web servers (such as IIS). The SOAP requests generated by the customer are embedded in an http post request and sent to the web server. The Web server then forwards these requests to the Web service request processor. For the VB 6 program, the Web service request processor is an ASP page or ISAPI extension that works with the soap toolkit component. For VB. NET programs, the Web service request processor is an ISAPI extension that comes with the. NET Framework. The request processor parses the received SOAP request, calls the web service, and then generates the corresponding soap response. After the Web server receives a soap response, it will send it back to the client through HTTP response.


Typical web service structure

Remote Procedure Call (RPC) and message transmission
The Web Service itself is actually implementing communications between applications. Now we have two methods for Application Communication: RPC (Remote Procedure Call) and message transmission. When RPC is used, the client calls the Remote Process on the server. Generally, a remote object is instantiated and its method and attributes are called. RPC emphasizes the remote object and its interface, that is, the parameters of attributes, methods, and calls. Remote Access to DCOM and. NET is an example of RPC.
Messages are generally transmitted in systems with lower coupling. The concept of message transmission is that the client sends a message to the server and waits for the response from the server. The message passing system emphasizes message sending and response, rather than the interface of remote objects. Because it is a message-based system, the coupling between the client and server is lower than that of the RPC method.
The RPC system tries to achieve the transparency of a location: the server exposes interfaces of remote objects, and the client is just like using interfaces of these objects locally, in this way, the underlying information is hidden, and the client does not need to know the machine on which the object is located. For example, if you call a remote object through DCOM in VB 6, your code looks like calling a local object. Message transmission is different. It emphasizes what the message is, regardless of what the message is after delivery. The customer does not need to know how the server is implemented and how messages are processed.
As we have already said, you can create a message server to call Objects Based on received messages. This is an effective implementation of RPC through message transmission. If you still operate on messages, you can call them message transmission. However, if you operate on remote objects, you should call it RPC.
If you want to implement an XML-based message delivery system, a lot of work will be concentrated on processing XML requests and response messages. Although VB 6 and VB. net, the tool that helps you build a web service has done a lot of work to process XML messages, but after all, all the data is sent and received in XML format, in many cases, you still need to process the message yourself. An in-depth understanding of XML and XML schema is essential to effectively implement the XML message system.

Create a Web Service
I know that you are eager to write some code to see what the web service is like. Now we will introduce how to use VB 6 and VB. NET to actually make a web service. The purpose of this section is to show you the functions of these tools, rather than explaining the working principles of Web Services in depth. The following sections will explain the Internal principles of Web Service, Microsoft soap toolkit,. net, and other tools.

Use soap Toolkit
Microsoft's soap toolkit V2 helps you turn COM components into Web Services. This tool is divided into three main parts: soapclient is a COM component used to call Web Service; soapserver is a component used to process SOAP requests and return soap responses; and a wsdl wizard, it can convert your type library into a wsdl document to expose it to Web Service customers.
Suppose you have a COM component that exposes a gettemperature method:
Public Function gettemperature (byval zipcode as string ,_
Byval Celsius as Boolean) as single

To turn this component into a web service, you can use the WSDL wizard. After the component you want to convert is provided, The Wizard will ask you to select the method you want to expose and point out the URL of the generated web service (such as http: // localhost/temperature /), and whether you want to use ASP or ISAPI as your request processor (1-2 ). Then the Wizard will ask you where the generated WSDL and ASP files should be stored.
Use the soap toolkit Wizard to convert COM components

Now it is time to call this web service. The method is to call the soapclient component in VB or any other language that can use Com. The following code demonstrates how to call the gettemperature method in WebService:

Dim soap as mssoaplib. soapclient
Set soap = new mssoaplib. soapclient
Soap. mssoapinit _
"Http: // localhost/temperature. WSDL"
Msgbox ("temperature is :"&_
Soap. gettemperature ("20171", false ))
First, call mssoapinit to pass the URL of the WSDL document to soapclient. The URL of the WSDL document is the URL you provided in the WSDL wizard plus "service name. WSDL 〉. Once the initialization is complete, the soapclient obtains all the web service methods, and you can directly call these methods. (T126)

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.