WebService (draft)

Source: Internet
Author: User
Tags soap wsdl

1. Overview

WebService is a remote invocation technique across programming languages and cross-operating system platforms.

WebService is a standard that is defined to enable the transmission of data between different applications over the network, which is independent of the specific language, as to which language provides the interface and which language to invoke to see the project.

2. Working principle

1.XML

XML is used to tag data (detailed descriptions of XML tags, which can be consulted) because, as we said above, webservice does not depend on a particular programming language. Different systems may be developed using different programming languages (as above: Project A uses PHP development, Project B uses Java development) so it is necessary to exchange data in a way that does not depend on a programming language, and most software integrates XML tags. Therefore, data is exchanged using XML format.

2.SOAP

SOAP is a special protocol used to transfer data. When the caller discovers the address that provides the WebService interface, it will connect using the SOAP protocol and the system that provides the webservice.

3.WSDL

WSDL is used to describe the rules of the interface that the client can invoke, all of which are defined in the WSDL file, and when a client initiates a call, the WebService provider references the WSDL rule to verify the legitimacy of the data request.

4.UDDI

UDDI lists the services that can be accessed. When a system needs data, it first looks for UDDI, finds the services that can get the data it needs from other than itself, and then makes the link to get the data. This is somewhat similar to the functionality of DNS.

The above describes the role of these four technologies throughout the WebService architecture, and below we will link the four items to see how the entire WebService architecture is implemented.

First, the provider of the WebService creates a new rule for some interfaces in the WSDL file and then sends the WSDL file to UDDI for coverage registration. The service requester (that is, the party that calls the WebService interface) connects UDDI first to query which provider has the data it needs, to find and then connect to the service provider, and to interact with the provider using the SOAP protocol. When the service party receives the request, the request is first validated, and the validation is based on the previously created WSDL rule. Validation will send the data in XML format to the requester by the later service party, and the same is done with the SOAP protocol. When the requester receives the XML data, the requester uses the XSD to verify the legitimacy of the XML data. Verify that the data is processed later.

The whole process can be reflected by:

3. Frame Selection

Apache CXF is the second-generation product of Codehausxfire, currently the best performance in different frameworks, should be a good choice for developers, which is not related to its own architectural design. Compared to other frameworks, CXF has several outstanding features: Support for Jax-WS, Spring integration, AEGI data binding, support for RESTful services, support for WS-*, Apache protocol, and code simplicity.

Apache Axis2 is the second-generation product of Apache Axis1, and is also very well architected, with key features: support for multiple languages (c/s + +), support for various specifications, pluggable modular design, and support for hot deployment. Performance is also excellent compared to CXF.

Resteasy may also be a good frame!

4. Testing

Visit: http://localhost:8080/wstest?wsdl

This XML file does does appear to has any style information associated with it. The document tree is shown below.

<!--

Published by Jax-ws RI at http://jax-ws.dev.java.net. Ri ' s version is JAX-ws RI 2.2.4-B01.

-

<!--

Generated by Jax-ws RI at http://jax-ws.dev.java.net. Ri ' s version is JAX-ws RI 2.2.4-B01.

-

<definitions xmlns:wsu= "Http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp= "Http://www.w3.org/ns/ws-policy" xmlns:wsp1_2= "Http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns: Wsam= "Http://www.w3.org/2007/05/addressing/metadata" xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/" xmlns: tns= "http://ws.pers.com/" xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" xmlns= "http://schemas.xmlsoap.org/wsdl/" Targetnamespace= "http://ws.pers.com/" name= "Hello" >

<types>

<xsd:schema>

<xsd:import namespace= "http://ws.pers.com/" schemalocation= "http://localhost:8080/wstest?xsd=1"/>

</xsd:schema>

</types>

<message name= "Sayhi" >

<part name= "Parameters" element= "Tns:sayhi"/>

</message>

<message name= "Sayhiresponse" >

<part name= "Parameters" element= "Tns:sayhiresponse"/>

</message>

<message name= "Sayhitouser" >

<part name= "Parameters" element= "Tns:sayhitouser"/>

</message>

<message name= "Sayhitouserresponse" >

<part name= "Parameters" element= "Tns:sayhitouserresponse"/>

</message>

<message name= "Sayhitouserlist" >

<part name= "Parameters" element= "Tns:sayhitouserlist"/>

</message>

<message name= "Sayhitouserlistresponse" >

<part name= "Parameters" element= "Tns:sayhitouserlistresponse"/>

</message>

<porttype name= "Hello" >

<operation name= "Sayhi" >

<input wsam:action= "Http://ws.pers.com/Hello/sayHiRequest" message= "Tns:sayhi"/>

<output wsam:action= "Http://ws.pers.com/Hello/sayHiResponse" message= "Tns:sayhiresponse"/>

</operation>

<operation name= "Sayhitouser" >

<input wsam:action= "Http://ws.pers.com/Hello/sayHiToUserRequest" message= "Tns:sayhitouser"/>

<output wsam:action= "Http://ws.pers.com/Hello/sayHiToUserResponse" message= "Tns:sayhitouserresponse"/>

</operation>

<operation name= "Sayhitouserlist" >

<input wsam:action= "Http://ws.pers.com/Hello/SayHiToUserListRequest" message= "Tns:sayhitouserlist"/>

<output wsam:action= "Http://ws.pers.com/Hello/SayHiToUserListResponse" message= "Tns:sayhitouserlistresponse"/ >

</operation>

</portType>

<binding name= "helloimplportbinding" type= "Tns:hello" >

<soap:binding transport= "http://schemas.xmlsoap.org/soap/http" style= "Document"/>

<operation name= "Sayhi" >

<soap:operation soapaction= ""/>

<input>

<soap:body use= "literal"/>

</input>

<output>

<soap:body use= "literal"/>

</output>

</operation>

<operation name= "Sayhitouser" >

<soap:operation soapaction= ""/>

<input>

<soap:body use= "literal"/>

</input>

<output>

<soap:body use= "literal"/>

</output>

</operation>

<operation name= "Sayhitouserlist" >

<soap:operation soapaction= ""/>

<input>

<soap:body use= "literal"/>

</input>

<output>

<soap:body use= "literal"/>

</output>

</operation>

</binding>

<service name= "Hello" >

<port name= "Helloimplport" binding= "tns:helloimplportbinding" >

<soap:address location= "Http://localhost:8080/wstest"/>

</port>

</service>

</definitions>

WebService (draft)

Related Article

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.