WebService get phone number attribution and get weather conditions steps, and create your own webservice

Source: Internet
Author: User

first, What is a Web service

Web Service is a development model that can be used to solve the problem of cross-network application integration, in order to ensure that the application services of different platforms can Interoperate.

Ii. three core of Web services

Soap:

SOAP, Simple Object Access Protocol, is an xml-based protocol that can be identified in a step-by Application. In addition, soap itself does not define any programming language, which allows soap to be delivered as a message to various remote SYSTEMS.

The transport protocol used by soap, which can be http,smtp,pop3,jms.

SOAP consists of 4 parts:

"soap Encapsulation (Envelope)":

Define a description of what the information describes, who is sending it, who should deal with it, and how to deal with their Framework.

"SOAP encoding Rules":

An instance of the data type that the application needs to Use.

"SOAP RPC":

Represents a contract that is called and answered in a remote Procedure.

"sopa binding":

Exchange information using the underlying Protocol.

Wsdl:

The WSDL (Web service Description language,web Service Description Language) is an XML document that defines operations and messages for a given WEB service receiver in an abstract way that is not specific to the Language.

Uddi:

UDDI (Universal Description Discovery and integration, Unified description Discovery and Integration Protocol) is a specification that defines the publishing, discovery, and management of information related to Web Services.

third, Jax-ws

Jsx-ws (Java API for XML Web Service). He is a technique used to simplify the work of building Web services and Web service clients using Java.

Iv.use of Web services in projects

1. Get phone number attribution to query

First Visit:

Http://www.webxml.com.cn/zh_cn/web_services.aspx

① Create a new MyEclipse project (WebService)

http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl

The above can be queried to the cell phone number attribution, below I will take you into the programming environment, how to get to the mobile phone number attribution to the place

First of All: the above path can not be lost, useful drops, you first look at your C packing directory has a CN folder, if there is, you have to delete it, and then do not need me to tell you how to appear,

 packagecn.com.test;Importcn.com.webxml.MobileCodeWS;Importcn.com.webxml.MobileCodeWSSoap;//http://www.webxml.com.cn/zh_cn/web_services.aspx//http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl public classMyTest { public Static voidmain (string[] Args) {mobilecodews ws=Newmobilecodews (); Mobilecodewssoap Soap=Ws.getmobilecodewssoap (); String Address=soap.getmobilecodeinfo ("1352269", "" ");    System.out.println (address); }}
Test Class

The first case above has been written, and then we create a webserver of our own. to delete the CN file under the C drive above, we have to write a own, so CN file We generate, and its use.

In addition, two projects under construction one is a service class, one is the client, (this avoids a problem, if written in the same project, the program can only run once, will be error,)

1  packagecn.happy.service;2 3 Importjavax.jws.WebService;4 Importjavax.xml.ws.Endpoint;5 6 //lan anyone accessing access7 @WebService8  public classHelloService {9      public voidsay (String Name) {TenSystem.out.println ("Hello" +name); one           a     } -     //This is the service side: -      public Static voidmain (String [] arg) { theEndpoint.publish ("http://localhost:50000/hello",NewHelloService ()); -System.out.println ("server is listening ..."); -     } -  +}
HelloService class

Paste the above Java file and create another Project. :

Output hellowxk, stating that the creation was Successful. If you run the second error, the customer service end to stop, in the open on the line, the Solution: small computer next to a inverted small triangle, click the switch stop service, in the deployment of services, error solved

1  packagecn.happy.test;2 3 Importcn.happy.service.HelloService;4 Importcn.happy.service.HelloServiceService;5 6  public classWstest {7 8     /**9      * @paramargsTen      */ one      public Static voidmain (string[] Args) { aHelloserviceservice service=NewHelloserviceservice (); -HelloService port=Service.gethelloserviceport (); -Port.say ("WXK"); the  -     } -  -}
wstest

Note that the CN file in the production of Java files, you start with the localhost, using localhost, IP is ip, do not mix, or Error.

②: Check the weather conditions in the area;

The first step is omitted, choose one of the more than 2,500 cities weather forecast Web Services (this case is to query the weather conditions in Beijing)

Warm tip: The number of days to check the weather is Limited.

And go back to the Myeclipse. (just the alternate path should play a role!)

As for weather acquisition, The project is published next time due to the number of runs Today. This article summarizes, if there is inappropriate, hope to point out, Thank you

WebService get phone number attribution and get weather conditions steps, and create your own webservice

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.