Java WebService implementation Phone number query

Source: Internet
Author: User

Before writing the code you should know what WebService is doing, WebService is neither a framework nor a technology, he is just a specification, a cross-platform, cross-language specification. The purpose of WebService is to solve different platforms, how applications written by different voices call each other

Popular point: Adding Java has the following methods
Public list<cat> getcatsbyuser (user user)

The requirement is that there is a C language written by the program, and he wants to call the Getcatsbyuser method above. The solution is webservice.

Directly say the operation Flow:

1. Open the URL http://www.webxml.com.cn/zh_cn/web_services.aspx, this URL inside

Choose

Arrow point to the URL, this URL is provided to us to access the national mobile phone number Attribution Data interface, open this URL is an XML file. The WSDL in front of the URL represents the WebService description Language:webservice description Language.

When you click inside, scroll down to the bottom to find

Mobilecodews is the service class, Mobilecodewssoap is the interface of this service class, you can get the data through this interface, these two classes are we need to query data behind the

The next step is to create a folder locally to hold the Java code file that you want to generate

I created a WebService folder under the Administactor.

The next step is to execute the command in the DOS interface, which needs to be executed under the C:\Users\Administrator\webservice you need to generate the code.

The first step is to go to the folder I created above, and the second step is to execute the generated Java code, "-S. "The URL that follows is the URL identified by the first image.

The red box will appear after the return of the part is successful, in the WebService folder will generate a Cn.com.webxml file structure directory. At this point, create a project in Eclipse,

, put the whole catalogue in the project and create a App.java class.

App.java is the client execution program.

App.java

 Package Cn.com.webxml;  Public class App {    publicstaticvoid  main (string[] args) {        new mobilecodews ();         = Ws.getmobilecodewssoap ();         NULL );        SYSTEM.OUT.PRINTLN (result);}    }

In the Code

Mobilecodews and
Mobilecodewssoap are the service interfaces and service classes mentioned in the XML file above,
Getmobilecodewssoap is A method of Mobilecodewssoap interface
The next run will give you a cell phone number attribution.

In fact, most of the code is generated directly, you need to write only app.java this class to invoke the service to get the data. May not be written very clearly, as a note

Java WebService implementation Phone number query

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.