Axis2 WebService development (1)

Source: Internet
Author: User
Document directory
  • Soap
  • Soap syntax rules

Before developing WebService, you should first take a look at what is WebService and understand the concept of WebService.

  1. Soap

Soap (Simple Object Access Protocol), about soap Tutorial: http://www.w3school.com.cn/soap/index.asp

L soap refers to Simple Object Access Protocol

L soap is a communication protocol

L soap is used for communication between applications

L soap is a format used to send messages.

L soap is designed for communication over the Internet

L soap is independent from the platform

L soap is independent of languages

L soap is based on XML

L soap is simple and scalable

L SOAP allows you to bypass the Firewall

L soap will be developed as W3C standards

  • Soap syntax rules

L soap messages must be encoded using XML

L soap messages must use the SOAP envelope namespace

L soap messages must use the soap encoding namespace

L soap messages cannot contain DTD references

L soap messages cannot contain XML processing instructions

The SOAP envelope element is the root element of soap and a required element. The SOAP header is an optional element that can contain application-specific information (such as authentication and payment) about soap messages ). If the Header element is provided, it must be the first child element of the envelope element. The soap Body element is required to include the actual SOAP message to be sent to the Message endpoint. Fault Element of soap, used to indicate error messages. If a fault element is provided, it must be a child element of the Body element. In a SOAP message, the fault element can only appear once.

 

  • WSDLIntroduction

What isWSDL?

  • WSDL refers to the Network Service Description Language
  • Write WSDL in XML
  • WSDL is an XML document.
  • WSDL is used to describe Network Services
  • WSDL can also be used to locate network services.
  • WSDL is not W3C standard yet

WSDLDescriptive Network Service (Web Services) 

WSDL refers to the Web Services Description Language ).

WSDL is a document written in XML. This document describes a web service. It specifies the service location and the operations (or methods) provided by the Service ).

InW3COfWSDLDevelopment History 

In March 2001, WSDL 1.1 was submitted to W3C XML activities related to XML protocols by IBM and Microsoft as a W3C record (W3C note) to describe network services.

(W3C record is for discussion only. The publication of a W3C record does not mean that it has been recognized by W3C, W3C team, or any W3C member .)

In July 2002, W3C released the first working draft of WSDL 1.2.

Read more about the standard status and timeline in our W3C tutorial.

WSDLDocument is just a simpleXMLDocumentation.

It contains a series of descriptions ofWeb Service.

WSDLDocument Structure

The WSDL document uses these main elements to describe a Web Service:

Element

Definition

<Porttype>

Operations performed by Web Service

<Message>

Message used by Web Service

<Types>

Data type used by Web Service

<Binding>

Communication protocol used by Web Service

The main structure of a wsdl document is similar to this:

<Definitions>

 

<Types>

Definition of types ........

</Types>

 

<Message>

Definition of a message ....

</Message>

 

<Porttype>

Definition of a port .......

</Porttype>

 

<Binding>

Definition of a binding ....

</Binding>

 

</Definitions>

The WSDL document can contain other elements, such as the extension element and a service element. This element can combine the definitions of several web services in a single WSDL document.

 

 

WSDLPort

<Porttype>Elements are the most important WSDL elements.

It describes a web service, executable operations, and related messages.

The <porttype> element can be compared to a function library (or a module or class) in a traditional programming language ).

WSDLMessage

<Message>An element defines the data elements of an operation.

Each message is composed of one or more parts. These components can be compared to a function call parameter in a traditional programming language.

WSDL types

<Types>Element defines the data type used by the web service.

To maximize platform neutrality, WSDL uses the XML Schema syntax to define data types.

WSDL bindings

<Binding>The element defines the Message format and protocol details for each port.

WSDLInstance

This is a simplified section of a wsdl document:

<Message name = "gettermrequest">

<Part name = "term" type = "XS: string"/>

</Message>

 

<Message name = "gettermresponse">

<Part name = "value" type = "XS: string"/>

</Message>

 

<Porttype name = "glossaryterms">

<Operation name = "getterm">

<Input message = "gettermrequest"/>

<Output Message = "gettermresponse"/>

</Operation>

</Porttype>

In this example,<Porttype>Element defines "glossaryterms" asPortTo define "getterm" asOperation.

The operation "getterm" has a "gettermrequest"Input messageAnd a file named "gettermresponse"Output Message.

<Message>Element can definePartsAnd the associated data types.

Compared with traditional programming, glossaryterms is a function library, while "getterm" is a function with the input parameter "gettermrequest" and the return parameter gettermresponse.

WSDLThe port can be described byWeb ServiceProvided interface (legal operation ).

WSDLPort

<Porttype>Elements are the most important WSDL elements.

It can describeWeb Service, ExecutableOperationAnd RelatedMessage.

A port defines a connection point pointing to a web service. This element can be compared to a function library (or a module or a class) in a traditional programming language, and each operation can be compared to a function in a traditional programming language.

Operation Type

Request-response is the most common operation type, but WSDL defines four types:

Type

Definition

One-way

This operation accepts messages but does not return a response.

Request-Response

This operation accepts a request and returns a response.

Solicit-Response

This operation can send a request and wait for a response.

Notification

This operation can send a message without waiting for a response.

One-wayOperation

One-way operation example:

<Message name = "newtermvalues">

<Part name = "term" type = "XS: string"/>

<Part name = "value" type = "XS: string"/>

</Message>

 

<Porttype name = "glossaryterms">

<Operation name = "setterm">

<Input name = "newterm" message = "newtermvalues"/>

</Operation>

</Porttype>

In this example, port "glossaryterms" defines a one-way operation named "setterm.

This "setterm" operation can accept the input of project messages in the new glossary. These messages use a message named "newtermvalues", which carries the input parameters "term" and "value ". However, no output is defined for this operation.

Request-ResponseOperation

Example of a request-response operation:

<Message name = "gettermrequest">

<Part name = "term" type = "XS: string"/>

</Message>

 

<Message name = "gettermresponse">

<Part name = "value" type = "XS: string"/>

</Message>

 

<Porttype name = "glossaryterms">

<Operation name = "getterm">

<Input message = "gettermrequest"/>

<Output Message = "gettermresponse"/>

</Operation>

</Porttype>

In this example, port "glossaryterms" defines a request-response operation named "getterm.

The "getterm" Operation requests an input message named "gettermrequest", which carries a parameter named "term" and returns an Output Message named "gettermresponse, the message carries a parameter named "value.

WSDLCan be boundWeb ServiceDefines the Message format and protocol details.

BindSoap

OneRequest-ResponseOperation example:

<Message name = "gettermrequest">

<Part name = "term" type = "XS: string"/>

</Message>

 

<Message name = "gettermresponse">

<Part name = "value" type = "XS: string"/>

</Message>

 

<Porttype name = "glossaryterms">

<Operation name = "getterm">

<Input message = "gettermrequest"/>

<Output Message = "gettermresponse"/>

</Operation>

</Porttype>

 

<Binding type = "glossaryterms" name = "B1">

<Soap: Binding style = "document"

Transport = "http://schemas.xmlsoap.org/soap/http"/>

<Operation>

<Soap: Operation

Soapaction = "http://example.com/getTerm"/>

<Input>

<Soap: Body use = "literal"/>

</Input>

<Output>

<Soap: Body use = "literal"/>

</Output>

</Operation>

</Binding>

BindingThe element has two attributes: name and type.

The name attribute defines the name of the binding, and the type attribute points to the port used for binding. In this example, it is the "glossaryterms" port.

Soap: BindingThe element has two attributes: The style attribute and the transport attribute.

The style attribute can be set to "RPC" or "document ". In this example, we use document. The transport attribute defines the SOAP protocol to be used. In this example, we use HTTP.

OperationThe element defines the operators provided by each port.

For each operation, the corresponding soap behavior needs to be defined. At the same time, you must encode the input and output. In this example, we use "literal ".

 

UDDIIs a directory service, which can be used by enterprisesWeb ServicesRegister and search.

UDDI, In English"Universal Description, discovery and Integration""General description, discovery, and integration services".

What isUDDI?

UDDI is a platform-independent framework used to describe services over the Internet, discover enterprises, and integrate enterprise services.

  • UDDI refers to the general description, discovery and integration service.
  • UDDI is a directory used to store information about Web Services.
  • UDDI is a directory on the Web Services interface described by WSDL.
  • UDDI communication through soap
  • UDDI is built into Microsoft's. NET platform.

UDDIBased on what?

UDDI uses W3C and IETF * Internet standards, such as XML, HTTP, and DNS protocols.

UDDI uses WSDL to describe the Web Services Interface

In addition, soap can also be used to implement cross-platform programming. As you know, soap is an XML Protocol Communication specification and relevant information can be found on W3C websites.

*Note:IETF-Internet Engineering Task Force

UDDIBenefits

Industries or enterprises of any size can benefit from UDDI.

Before UDDI, there was no Internet standard for enterprises to provide information about their products and services to their enterprises and partners. There is no way to integrate into each other's systems and processes.

The problems that the UDDI specification helps us solve:

  • This makes it possible to find the right enterprises in millions of online enterprises.
  • Define how to start a business once the preferred enterprise is discovered
  • Expand new customers and add access to current customers
  • Expand sales and market scope
  • Meet user-driven needs and clear obstacles for rapid cooperation in the global Internet Economy

UDDIHow to Use

If the industry releases a UDDI standard for flight Rate Detection and booking, airlines can register their services in a UDDI directory. Then the travel agency can search for the UDDI directory to find the airline reservation interface. When this interface is found, the travel agency can immediately communicate with this service, because it uses a set of well-defined booking interfaces.

WHO is supportingUDDI?

UDDI is a cross-industry research project driven by all major platform and software providers, such as Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, sun is also a group of market operators and a leader in e-commerce.

Hundreds of companies have joined the UDDI group.

Description onW3CComplete draft of workThe WSDL 1.2The syntax is already listed below:

<wsdl:definitions name="nmtoken"? targetNamespace="uri">
 
    <import namespace="uri" location="uri"/> *
         
    <wsdl:documentation .... /> ?
 
    <wsdl:types> ?
        <wsdl:documentation .... /> ?
        <xsd:schema .... /> *
    </wsdl:types>
 
    <wsdl:message name="ncname"> *
        <wsdl:documentation .... /> ?
        <part name="ncname" element="qname"? type="qname"?/> *
    </wsdl:message>
 
    <wsdl:portType name="ncname"> *
        <wsdl:documentation .... /> ?
        <wsdl:operation name="ncname"> *
            <wsdl:documentation .... /> ?
            <wsdl:input message="qname"> ?
                <wsdl:documentation .... /> ?
            </wsdl:input>
            <wsdl:output message="qname"> ?
                <wsdl:documentation .... /> ?
            </wsdl:output>
            <wsdl:fault name="ncname" message="qname"> *
                <wsdl:documentation .... /> ?
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:portType>
 
    <wsdl:serviceType name="ncname"> *
        <wsdl:portType name="qname"/> +
    </wsdl:serviceType>
 
    <wsdl:binding name="ncname" type="qname"> *
        <wsdl:documentation .... /> ?
        <-- binding details --> *
        <wsdl:operation name="ncname"> *
            <wsdl:documentation .... /> ?
            <-- binding details --> *
            <wsdl:input> ?
                <wsdl:documentation .... /> ?
                <-- binding details -->
            </wsdl:input>
            <wsdl:output> ?
                <wsdl:documentation .... /> ?
                <-- binding details --> *
            </wsdl:output>
            <wsdl:fault name="ncname"> *
                <wsdl:documentation .... /> ?
                <-- binding details --> *
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
 
    <wsdl:service name="ncname" serviceType="qname"> *
        <wsdl:documentation .... /> ?
        <wsdl:port name="ncname" binding="qname"> *
            <wsdl:documentation .... /> ?
            <-- address details -->
        </wsdl:port>
    </wsdl:service>
 
</wsdl:definitions>

 

With the above knowledge, you can have a very deep understanding of WSDL. In fact, WSDL itself is very simple, next, we can use the WSDL language to define the interface and then develop it.

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.