The emergence of Web services has led to the direct calls of many system projects. The code is undoubtedly hidden and encapsulated.
The main components of Web Service:
SOAP: (Simple Object Access Protocol) Simple Object Access Protocol, which must be followed for the entire web service. Only through this protocol can cross-platform communication or cross-firewall direct communication be achieved.
WSDL :( Web Service Description Language) Web Service Description Language. In fact, WSDL is an XML document. For example, the carrier of the results returned by a Web service call and the carrier of the parameters sent to the Web service. All are transmitted in the form of XML documents
UDDI :( Universal Description Discovery and Integration): unified Description, Discovery and Integration protocols. It is used to record the Web Service information and help you query the Web service. Generally, it refers to the registration of Web Service to UDDI. Unless you want others to know your Web Service.
The whole process of calling Web Services on the client requires serialization and deserialization.
The following describes how to call a Web Service:
1. synchronous call
For synchronous calls, we all know that the code execution sequence is from top to bottom. If the Code contains a Web service method, it can continue to run only after the Web service method is executed. If some factors affect the code execution. For example, a network problem must be considered. It is not good for users to wait for half a day. No company is willing to do this. So there is another method of calling.
2. asynchronous call
It is a little complicated for asynchronous calls. Let's take a look.
You do not need to change the Web service code. Only client calls need to change the code
A. You need to deploy the encoded Web service on the IIS server, create A new website, select the directory for storing the website, and call debugging in the browser. Prevents call errors. If everything is OK,
B. It is very important to add Web references to the client website. Then select local
Select the Web service in the Local Computer. By the way, the first option is provided. If there is a Web Service Project in the client solution, you can directly select the first one. Then we can see that the Web reference name on the right is defined by a person. However, the standard naming method is recommended.
After confirmation, you can see a SearchBookServices folder in the project, which stores the files automatically generated by VS. A brief description is as follows:
Disco: discovery document that contains reference to available resources of all Web Services
Wsdl: The current web Service wsdl File
Discomap: a document that contains references to. disco and. wsdl files.
The following is the asynchronous call method:
First, you must reference the namespace, that is, the custom namespace.
At the bottom is the namespace defined by the author.
Instantiate a global private service class,
Here I wrote a simple asynchronous call method. This is the Web Service call. Of course, this is just a simple introduction. Help you recall.
Advantages of Web Services:
A. Cross-platform communication is supported.
B. Cross-firewall communication
C. B2B (Business To Business) Integration
D. reuse of software and data
Finally, you don't have to forget that the Web service calling methods are synchronous and asynchronous. Old habits-I hope you will like a nostalgic image today.