WebServices Learning One (Understanding Foundation and function. )

Source: Internet
Author: User
Tags wsdl

First, Part I

1, with a few questions to learn:

L What is WebService?

L What can it do?

L Why study WebService?

l What is the purpose of learning WebService?

    1. A: WebService, as the name implies, is a web-based service. It uses the Web (HTTP) method to receive and respond to some kind of request from the external system. This allows for remote invocation.

    1. We can call the Internet to query the Weather information Web service, and then embed it in our program (c/S or b/S program), when the user from our network to see the weather information, he will think we provide him with a lot of information services, but in fact we did nothing, Just a simple call to a piece of code on the server .

    1. Learning WebService can publish your service (a piece of code) to the Internet for someone else to call, or you can call the WebService published on someone else's machine, just like using your own code.

L Understand from WebService's working mode, it has no essential difference with ordinary Web programs (such as ASP, JSP, etc.), and it is based on the HTTP Transfer Protocol program.

The data used by L WebService is based on XML format. The current standard webservice mainly uses the SOAP protocol in the data format. The SOAP protocol is actually a text protocol based on XML encoding specification.

Part II: Before you begin, you must starters understand several nouns:

Noun 1:xml.       Extensible Markup Language-Extensible Markup Language XML, used to transfer formatted data, is the foundation of Web services.       The namespace-namespace.            xmlns= "http://itcast.cn" uses the default namespace.            xmlns:itcast= "http://itcast.cn" uses the namespace of the specified name.       noun 2:wsdl–webservice Description language–web Service Description Language.            • Explain where the service is-address in XML form.            • Describe what method the service provides in XML form – how to invoke it.              L noun 3:soap-simple Object access Protocol (Simple Object Access Protocol) soap is used as an XML-based protocol for transmitting data online.            soap = +xml data on the basis of HTTP.            The soap is HTTP-based. The composition of the soap is as follows: envelope– necessary parts.            appears as the root element of the XML.          headers– is optional. body– is necessary. In the body section, the method that contains the server to be executed. And the data sent to the server.

First, the WSDL description:

<?xml version= "1.0" encoding= "UTF8"?>

<definitions xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:tns= "http://ws.itcast.cn/" xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"

xmlns= "http://schemas.xmlsoap.org/wsdl/" targetnamespace= "http://ws.itcast.cn/"

Name= "Helloserviceservice" >

<types>

<xsd:schema>

<xsd:import namespace= "http://ws.itcast.cn/"

schemalocation= "Http://localhost:9999/hello?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>

<porttype name= "HelloService" >

<operation name= "Sayhi" >

<input message= "Tns:sayhi"/>

<output message= "Tns:sayhiresponse"/>

</operation>

</portType>

<binding name= "helloserviceportbinding" type= "Tns:helloservice" >

<soap:binding transport= "Http://schemas.xmlsoap.org/soap/http"

style= "Document"/>

<operation name= "Sayhi" >--------//ws methods and services provided

<soap:operation soapaction= ""/>

<input>

<soap:body use= "literal"/>

</input>

<output>

<soap:body use= "literal"/>

</output>

</operation>

</binding>

<service name= "Helloserviceservice" > Name of the--------//ws

<port name= "Helloserviceport" binding= "tns:helloserviceportbinding" >

<soap:address location= "Http://localhost:9999/hello"/>--------//ws Address

</port>

</service>

</definitions>

Second, the SOAP description:

Request:

Post/webservices/mobilecodews.asmx http/1.1

Host:webservice.webxml.com.cn

Content-type:text/xml; Charset=utf-8

Content-length:length

SOAPAction: "Http://WebXml.com.cn/getMobileCodeInfo"------because it is sending data on HTTP, you must first follow the HTTP protocol

<?xml version= "1.0" encoding= "Utf-8"?>

<soap:envelope xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

Xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"

xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/" >

<soap:Body>

<getmobilecodeinfo xmlns= "http://WebXml.com.cn/" >

<mobileCode>string</mobileCode>

<userID>string</userID>

</getMobileCodeInfo>

</soap:Body>

</soap:Envelope>

-------1, the XML part, the SOAP protocol, must contain

--------2, envelope elements and body elements.

Response:

http/1.1 OK

Content-type:text/xml; Charset=utf-8

Content-length:length

<?xml version= "1.0" encoding= "Utf-8"?>

<soap:envelope xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

Xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"

xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/" >

<soap:Body>

<getmobilecodeinforesponse xmlns= "http://WebXml.com.cn/" >

<getMobileCodeInfoResult>string</getMobileCodeInfoResult>

</getMobileCodeInfoResponse>

</soap:Body>

</soap:Envelope>

WebServices Learning One (Understanding Foundation and function. )

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.