Getting Started with WebServices

Source: Internet
Author: User
Tags abstract abstract definition definition bind soap web services xmlns wsdl
Services|web [Pre]webservices Introduction
--Theoretical articles
Lichunlin Technology (China) Co., Ltd. [/pre]
This document is an entry-level document produced with CTRL + C-> Ctrl + V, primarily to illustrate what is a webservices,webservices architecture and several related XML documents. Because the younger brother knowledge and technology is very limited, the article in the wrong place please brother to correct, little brother here thanked.
What is WebServices?
On the surface: WebServices is an application that exposes an API to the outside world that can be invoked through the Web. This means that you can programmatically invoke the application through the Web. We call the application that calls this webservices the customer.
A more professional description is as follows: WebServices is an interface that describes operations that use standardized XML messaging mechanisms to access these operations over the network. WebServices is a description of the service described by standard, canonical XML concepts, called WebServices. This description includes all the details required for the service interaction, including the message format (detailed description of operations), transport protocol, and location. This interface hides the details of implementing the service, allowing the service to be used independently of the hardware or software platform on which the service is based, and the programming language in which the service is written. This allows and supports webservices based applications to become loosely coupled, component-oriented, and across-technology implementations. WebServices perform a specific task or set of tasks. WebServices can be used individually or together with other webservices to implement complex aggregation or business transactions, as well as Enterprise Integration (EAI).
WebServices model
The WebServices architecture is based on the interaction between three roles (service providers, service registries, and service requesters). Interactions involve publishing, finding, and binding operations. These roles and actions work with the WebServices widget:

WebServices software module and its description. In a typical (not a SARS ^_^) scenario, a service provider hosts a network-accessible software module (an implementation of webservices). The service provider defines the service description of the WEB service and publishes it to the service requester or service registry. The service requester uses a lookup operation to retrieve the service description from the local or service registry, and then uses the service description to bind to the service provider and invoke or interact with the WEB service implementation. The service provider and the service requester role are logical structures, so the service can represent two characteristics. The following figure illustrates these operations, the components that provide these operations, and the interactions between them.

WebServices protocol Stack
To perform the three operations of publishing, discovery, and binding in an interoperable manner, you must have a webservices protocol stack that contains each layer of standard. The following figure shows a conceptual webservices protocol stack. The above layers are built on the functions provided below. The vertical bar represents the requirements that each layer must meet in the protocol stack. The text on the left represents the standard technology applied to that layer of the protocol stack.

The following is a rough description of each layer in the conceptual stack above:
The first layer (network): This layer of these protocols are now using a more extensive agreement, now HTTP is the most used, the benefits are obvious, the other I will not say more. (Mainly I am afraid that I will be wrong to speak out, be ridiculed by everyone.) *_*)。
The second layer (xml-based messaging) is the main embodiment of how to invoke WebServices. There are now two main types of applications, one is XML-RPC (Xml-remote Procedure call) and the other is soap (simple Object Access protocal). Soap, by contrast, has some advantages over XML-RPC: SOAP is easier to handle complex data (such as arrays, etc.) than XML-RPC; XML-RPC does not standardize error codes; Here we look at soap:
What is SOAP?
A simple understanding of soap:
SOAP is an XML Application,soap simple understanding, is such an open protocol Soap=rpc+http+xml: The use of HTTP as the underlying communication protocol, RPC as a consistent way of invocation, XML as a data transfer format, Allows service providers and service customers to interact with the Internet through firewalls. The following figure:

A further understanding of soap:
The SOAP Simple Object Access Protocol is a simple protocol for exchanging information in a decentralized or distributed environment, an xml-based protocol that consists of four parts: the soap wrapper (envelop), which encapsulates a description of what is in the message and who sent it. Who should accept and deal with it and how to deal with them, as in the following illustration, the SOAP Encoding Rules (Encoding rules), which represent instances of the data types that the application needs to use, and generally follow the XmlSchema (a series of simple data types defined) specifications; A SOAP RPC representation (RPC representation) that represents a contract for remote procedure invocation and response; SOAP binding (binding), which uses the underlying protocol to exchange information. Although these four parts are defined as a whole as part of soap, they are functionally intersecting and independent of each other. In particular, envelopes and coding rules are defined in different XML namespaces (namespace), making the definition simpler.

Figure: Soap Encapsulation (envelop)
Let's take a look at a soap example:
[Pre] Post/calendar-request http/1.1
Host:www.todaytech.com.cn
Content-type:text/plain; charset= "Utf-8"
content-length:507
SOAPAction: ""

<soapenv:envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/"
Xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" >
<soapenv:Body>
<ns1:searchpaynoteresponse
Soapenv:encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1= "Http://external.charge.gfmis.todaytech.com" >
<searchpaynotereturn href= "#id0"/>
</ns1:searchPaynoteResponse>
<multiref id= "id0" soapenc:root= "0" soapenv:encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Xsi:type= "Ns2:externalpaynotevo"
Xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2= "Http://vo.charge.gfmis.todaytech.com" >
<paynoteno xsi:type= "Xsd:string" >0300000003004</paynoteNO>
<startdate xsi:type= "xsd:string" xsi:nil= "true"/>
<disaid xsi:type= "xsd:string" xsi:nil= "true"/>
<annotation xsi:type= "xsd:string" xsi:nil= "true"/>
<chargeitemno3 xsi:type= "xsd:string" xsi:nil= "true"/>
<amount xsi:type= "Xsd:double" >0.0</amount>
<chargeitemno2 xsi:type= "xsd:string" xsi:nil= "true"/>
<loginkey xsi:type= "Xsd:string" >YCpTEwKEw</loginKey>
<chargeitemno1 xsi:type= "xsd:string" xsi:nil= "true"/>
<usersign xsi:type= "xsd:string" xsi:nil= "true"/>
<operator xsi:type= "xsd:string" xsi:nil= "true"/>
<usercert xsi:type= "xsd:string" xsi:nil= "true"/>
<quantity3 xsi:type= "Xsd:double" >0.0</quantity3>
<quantity2 xsi:type= "Xsd:double" >0.0</quantity2>
<unitname xsi:type= "xsd:string" xsi:nil= "true"/>
<srvsign xsi:type= "xsd:string" xsi:nil= "true"/>
<quantity1 xsi:type= "Xsd:double" >0.0</quantity1>
<srvcert xsi:type= "xsd:string" xsi:nil= "true"/>
<externalpaynoteno xsi:type= "xsd:string" xsi:nil= "true"/>
<status xsi:type= "Xsd:int" >1</status>
<randstr xsi:type= "xsd:string" xsi:nil= "true"/>
<returncode xsi:type= "Xsd:int" >0</returnCode>
<enddate xsi:type= "xsd:string" xsi:nil= "true"/>
<price3 xsi:type= "Xsd:double" >0.0</price3>
<price2 xsi:type= "Xsd:double" >0.0</price2>
<price1 xsi:type= "Xsd:double" >0.0</price1>
<unitno xsi:type= "xsd:string" xsi:nil= "true"/>
<payername xsi:type= "xsd:string" xsi:nil= "true"/>
</multiRef>
</soapenv:Body>
</soapenv:envelope>[/pre]
Third layer (service Description): In this layer is mainly the description of our services, to the client to explain our services, tell the client, we provide what kind of interface to call (WHAT), how to call (how), where to call (where). The main protocol in this layer is the WSDL (Web Services Description Language). WSDL is an XML application that is used to describe the what,how,where of our interfaces to clients, which means that the WSDL service definition provides a machine-recognized SDK documentation for distributed systems. And can be used to describe the details involved in automating application communication.
A WSDL document defines a Web service as a collection of service access points or ports. In WSDL, because the abstract definition of a service access point and message has been detached from a specific service deployment or data format binding, the abstract definition can be reused: a message, an abstract description of the exchanged data, and a port type, which refers to an abstract collection of operations. The specific protocol and data format specification for a particular port type constitutes a binding that can be used again. The Web Access address is associated with a reusable binding, you can define a port, and the collection of ports is defined as a service. Therefore, the WSDL document uses the following elements in the definition of the Web service:
types-A container of data type definitions that uses a type system (generally using the type system in an XML Schema).
message-Abstract typed definition of the data structure of a communication message. Use the type defined by types to define the data structure of the entire message.
operation-An abstract description of the operations supported in the service, typically a single Operation describes a request/response message pair for an access portal.
porttype-An abstract collection of operations supported by an access entry point type that can be supported by one or more service access points.
binding-binding of specific protocol and data format specifications for a specific port type.
Port-Defines a single service access point for a protocol/data format binding and a combination of specific Web Access addresses.
Service-A collection of related service access points.
We can refer to the following figure to understand the structure of the WSDL document:

Description: Of which,
Types is a container of data type definitions that contains all the type definitions of the XML elements required in the message definition, and it generally follows the XmlSchema specification.
The message specifically defines the data structure of the messages used in the communication, which contains a set of part elements, each of which is a component of the final message, each of which references a datatype to represent its structure. The part element does not support nesting (you can use datatype to do this), and it is all tied up.
PortType specifically defines a type of service access entry, what is the type of access entry? is the mode and format of the incoming/outgoing message. A porttype can contain several operation, while one operation refers to a type of invocation supported by the Access portal. Four types of access gate calls are supported in the WSDL:
1. Single request;
2. Single response;
3. Request/Response;
4. Response/Request.
Service describes the deployment details of all access portals provided by a specific deployed Web service, which often contains multiple service access portals, and each access portal is described with a port element.
Port describes the deployment details of a service access portal, including which web address (URL) to access, what message invocation mode should be used, and so on. Where the message invocation pattern is expressed by using the binding structure.
The binding structure defines a porttype that is bound to a specific network transport protocol or message Transfer Protocol, from which the description is related to the deployment of a specific service. For example, you can bind the porttype to the soap/http, or you can bind the porttype to the MIME/SMTP.

Here we give a document instance of WSDL:
[Pre]<?xml version= "1.0" encoding= "UTF-8"?>
<wsdl:definitions targetnamespace= "Http://external.charge.gfmis.todaytech.com"
Xmlns= "http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap= "Http://xml.apache.org/xml-soap"
Xmlns:impl= "Http://external.charge.gfmis.todaytech.com-impl"
xmlns:intf= "Http://external.charge.gfmis.todaytech.com"
Xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/"
Xmlns:tns2= "Http://vo.charge.gfmis.todaytech.com"
Xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap= "http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" >
<wsdl:types>
<schema targetnamespace= "Http://vo.charge.gfmis.todaytech.com"
xmlns= "Http://www.w3.org/2001/XMLSchema" >
<import namespace= "http://schemas.xmlsoap.org/soap/encoding/"/>
<complextype name= "Externalpaynotevo" >
<sequence>
<element name= "Amount" type= "xsd:double"/>
<element name= "Annotation" nillable= "true" type= "xsd:string"/>
<element name= "chargeItemNO1" nillable= "true" type= "xsd:string"/>
<element name= "chargeItemNO2" nillable= "true" type= "xsd:string"/>
<element name= "ChargeItemNO3" nillable= "true" type= "xsd:string"/>
<element name= "Disaid" nillable= "true" type= "xsd:string"/>
<element name= "EndDate" nillable= "true" type= "xsd:string"/>
<element name= "Externalpaynoteno" nillable= "true" type= "xsd:string"/>
<element name= "Loginkey" nillable= "true" type= "xsd:string"/>
<element name= "operator" nillable= "true" type= "xsd:string"/>
<element name= "Payername" nillable= "true" type= "xsd:string"/>
<element name= "Paynoteno" nillable= "true" type= "xsd:string"/>
<element name= "Price1" type= "xsd:double"/>
<element name= "Price2" type= "xsd:double"/>
<element name= "Price3" type= "xsd:double"/>
<element name= "quantity1" type= "xsd:double"/>
<element name= "Quantity2" type= "xsd:double"/>
<element name= "Quantity3" type= "xsd:double"/>
<element name= "Randstr" nillable= "true" type= "xsd:string"/>
<element name= "ReturnCode" type= "Xsd:int"/>
<element name= "Srvcert" nillable= "true" type= "xsd:string"/>
<element name= "Srvsign" nillable= "true" type= "xsd:string"/>
<element name= "StartDate" nillable= "true" type= "xsd:string"/>
<element name= "status" type= "Xsd:int"/>
<element name= "Unitno" nillable= "true" type= "xsd:string"/>
<element name= "Unitname" nillable= "true" type= "xsd:string"/>
<element name= "Usercert" nillable= "true" type= "xsd:string"/>
<element name= "Usersign" nillable= "true" type= "xsd:string"/>
</sequence>
</complexType>
<element name= "Externalpaynotevo" nillable= "true" type= "Tns2:externalpaynotevo"/>
</schema>
</wsdl:types>

<wsdl:message name= "Logoutrequest" >
<wsdl:part name= "Epnvo" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Searchpaynoteresponse" >
<wsdl:part name= "Searchpaynotereturn" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Searchpaynoterequest" >
<wsdl:part name= "Epnvo" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Genpaynoteresponse" >
<wsdl:part name= "Genpaynotereturn" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Loginresponse" >
<wsdl:part name= "Loginreturn" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Logoutresponse" >
<wsdl:part name= "Logoutreturn" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Genpaynoterequest" >
<wsdl:part name= "EPVO" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:message name= "Loginrequest" >
<wsdl:part name= "Epnvo" type= "Tns2:externalpaynotevo"/>
</wsdl:message>
<wsdl:porttype name= "Externalinterface" >
<wsdl:operation name= "Login" parameterorder= "Epnvo" >
<wsdl:input message= "Intf:loginrequest" name= "Loginrequest"/>
<wsdl:output message= "Intf:loginresponse" name= "Loginresponse"/>
</wsdl:operation>
<wsdl:operation name= "Logout" parameterorder= "Epnvo" >
<wsdl:input message= "Intf:logoutrequest" name= "Logoutrequest"/>
<wsdl:output message= "Intf:logoutresponse" name= "Logoutresponse"/>
</wsdl:operation>
<wsdl:operation name= "Genpaynote" parameterorder= "EPVO" >
<wsdl:input message= "Intf:genpaynoterequest"
Name= "Genpaynoterequest"/>
<wsdl:output message= "Intf:genpaynoteresponse"
Name= "Genpaynoteresponse"/>
</wsdl:operation>
<wsdl:operation name= "Searchpaynote" parameterorder= "Epnvo" >
<wsdl:input message= "Intf:searchpaynoterequest"
Name= "Searchpaynoterequest"/>
<wsdl:output message= "Intf:searchpaynoteresponse"
Name= "Searchpaynoteresponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name= "Externalinterfacesoapbinding"
Type= "Intf:externalinterface" >
<wsdlsoap:binding style= "RPC"
transport= "Http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name= "Login" >
<wsdlsoap:operation soapaction= ""/>
<wsdl:input name= "Loginrequest" >
<wsdlsoap:body
Encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:input>
<wsdl:output name= "Loginresponse" >
<wsdlsoap:body
Encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name= "Logout" >
<wsdlsoap:operation soapaction= ""/>
<wsdl:input name= "Logoutrequest" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:input>
<wsdl:output name= "Logoutresponse" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name= "Genpaynote" >
<wsdlsoap:operation soapaction= ""/>
<wsdl:input name= "Genpaynoterequest" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:input>
<wsdl:output name= "Genpaynoteresponse" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name= "Searchpaynote" >
<wsdlsoap:operation soapaction= ""/>
<wsdl:input name= "Searchpaynoterequest" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:input>
<wsdl:output name= "Searchpaynoteresponse" >
<wsdlsoap:body encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
Namespace= "http://external.charge.gfmis.todaytech.com" use= "encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name= "Externalinterfaceservice" >
<wsdl:port binding= "intf:externalinterfacesoapbinding" name= "Externalinterface" >

<wsdlsoap:address location= "Http://localhost:7001/gfmis/services/ExternalInterface"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>[/pre]
Fourth floor (Service publication):
Fifth floor (Service Discovery): These two layers are about the UDDI agreement, we temporarily do not use, now also temporarily not, later up (^_^).





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.