A typical Web service structure

Source: Internet
Author: User
Tags http post implement soap wsdl
Web-typical Web service architecture
(Cola November 01, 2001 18:35)

A typical Web service structure.

No matter what tools or languages your Web service is written for, as long as you use the SOAP protocol to invoke it over HTTP, the overall structure should look like the following figure. Typically, you build your Web service with your favorite language, such as VB 6 or vb.net, and then expose it to web customers with SOAP Toolkit or. NET built-in support. As a result, customers in any language, any platform, can read their WSDL documents to invoke this Web service. The client describes the document based on the WSDL, and a SOAP request message is generated. Web service is placed behind a Web server (such as IIS), and a client-generated SOAP request is embedded in an HTTP POST request and sent to the Web server. The Web server then forwarded these requests to the Web Service request processor. For VB 6 programs, the WEB service request processor is an ASP page or ISAPI extension that works in conjunction with SOAP Toolkit components. For the vb.net program, the WEB service request processor is a. NET framework with its own ISAPI extension. The purpose of the request processor is to parse the received SOAP request, invoke the Web service, and then generate the corresponding SOAP reply. Once the Web server gets a soap reply, it is sent back to the client via an HTTP reply.

Typical Web service structure, click on small image to enlarge

Remote Procedure Call (RPC) and message delivery
The WEB service itself is actually implementing communication between applications. We now have two methods of application communication: RPC (Remote procedure Call) and message delivery. When using RPC, the concept of the client is to invoke a remote procedure on the server, typically by instantiating a remote object and calling its methods and properties. RPC emphasizes the remote object and its interface, that is, the properties, methods, and parameters of the call. Both DCOM and. NET remote access are examples of RPC.
Message delivery is typically in a system with a lower degree of coupling. The concept of message delivery is that the client sends a message to the server and waits for the server to respond. Messaging systems emphasize the sending and responding of messages, not the interface of remote objects. Because it is a message based system, the coupling between the client and server is lower than the RPC method.
The RPC system attempts to achieve a position of transparency: the server exposes the interface of the remote object, and the client is like using the interfaces of those objects that are used locally, so that the underlying information is hidden, and the client does not need to know which machine the object is on. For example, you call a remote object through DCOM in VB 6, and your code looks just like the local object. Messaging, however, is different, emphasizing what is being passed, but regardless of what the message passes past. The customer does not need to know how the server is implemented, and how the message is handled.
As we have said, you can create a message server that invokes the object based on the message you receive. This is implemented by means of message delivery method effectively RPC. If the customer is still working on the message's way of thinking, then you can call it message delivery. But if the customer is working on a remote object's way of thinking, then you should call it RPC.
If you want to implement an xml-based messaging system, a lot of work will be focused on processing XML requests and answering messages. Although VB 6 and vb.net, the tools that help you build Web service have done a lot of work on XML message processing, but after all, all data is sent and received in XML form, in many cases you still need to do some processing of the message. An in-depth understanding of XML and XML schemas is essential to effectively implement XML message systems.


setting up a Web Service
I know you're impatient to write code and see what the Web service is like. So let's now describe how to use VB 6 and vb.net to actually make a Web service. The purpose of this section is simply to show you the capabilities of these tools, rather than to delve into how the Web service works. The chapters later in this book will show you the inner workings of Web service and Microsoft SOAP Toolkit and. NET Tools.

using SOAP Toolkit
Microsoft's Soap Toolkit V2 helps you turn COM components into Web service. This set of tools is divided into three main parts: SoapClient is a COM component for invoking Web service; SoapServer is a component that handles SOAP requests and returns SOAP replies; and a WSDL wizard that can put your type The library is converted into a WSDL document to expose to the customer of the Web service.
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. Given the component you want to convert, the wizard will ask you to select the method you want to expose, indicate the URL of the generated Web service (such as http://localhost/Temperature/), and whether you want to use ASP or ISAPI to do your request processor ( As shown in Figure 1-2). The wizard then asks you if the WSDL and ASP files you generated should be in that directory.

Using the SOAP Toolkit Wizard to convert COM components, click the thumbnail to enlarge

Now it's time to call this Web service. The method is to invoke the SoapClient component in VB or any other language that can use COM. The following code demonstrates how to invoke the Gettemperature method in WebService:
Dim soap as Mssoaplib.soapclient
Set soap = New mssoaplib.soapclient
Soap.mssoapinit _
"HTTP://LOCALHOST/TEMPERATURE/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 gave in the WSDL wizard plus the 〈service name. wsdl〉. Once the initialization is complete, soapclient gets all the methods of the Web service, and you can call these methods directly.


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.