WebService Study notes-hello World

Source: Internet
Author: User

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/27/wKiom1Q3dkWB8TjnAAEeii4Y_so241.jpg "title=" Qq20141010140115.png "alt=" Wkiom1q3dkwb8tjnaaeeii4y_so241.jpg "/>

Contains a server and a client.

Server-side

Hellows.java interface

/** * SEI * */@WebServicepublic interface Hellows {@WebMethodpublic string SayHello (string name);}

Hellowsimpl.java implementing the Hellows.java interface

@WebServicepublic class Hellowsimpl implements hellows{@Overridepublic string SayHello (string name) { SYSTEM.OUT.PRINTLN ("Server says hello to" + name); return "Hello" + Name;}

Servertest Publishing Services

/** * Released WebService * */public class Servertest {public static void main (string[] args) {String address = "http://192.168.1 3.232:8989/ws_01/umgsai "; Endpoint.publish (Address, New Hellowsimpl ()); System.out.println ("Publish Success");}}

Client

① uses the Wsimport tool that comes with the JDK to generate client code based on the network URL

into the target directory in CMD, in the example of the SRC directory in the client project, execute

Wsimport-keep http://192.168.13.232:8989/ws_01/umgsai?wsdl

Directories and files are generated in src after execution

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/29/wKioL1Q3d-3jTWQaAAB-Oxac2vw074.jpg "title=" Qq20141010140712.png "alt=" Wkiol1q3d-3jtwqaaab-oxac2vw074.jpg "/>

② uses the Wsimport tool that comes with the JDK to generate client code based on the WSDL file

Open in Browser

http://192.168.13.232:8989/ws_01/umgsai?wsdl

Then save the code as a umgsai.wsdl file. Change the 8989 port in the file to 8080

Then configure a port forwarding in eclipse

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/2A/wKioL1Q3f2yA1C7BAADkcaISkZM713.jpg "title=" Qq20141010143927.png "alt=" Wkiol1q3f2ya1c7baadkcaiskzm713.jpg "/>

into the target directory in CMD, in the example of the SRC directory in the client project, execute

Wsimport-keep E:\umgsai\workspace\WS_Client\src\umgsai.wsdl

Directories and files are generated in src after execution

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/29/wKioL1Q3d-3jTWQaAAB-Oxac2vw074.jpg "title=" Qq20141010140712.png "alt=" Wkiol1q3d-3jtwqaaab-oxac2vw074.jpg "/>


Client Calls

Then call the server-side function in the Clienttest.java

public class Clienttest {public static void main (string[] args) {Hellowsimplservice factory = new Hellowsimplservice (); Hellowsimpl hellows = Factory.gethellowsimplport (); System.out.println (Hellows.getclass ()); String result = Hellows.sayhello ("Tom"); SYSTEM.OUT.PRINTLN (result);}}


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/28/wKiom1Q3gLPC0vJZAAH8imENF3M577.jpg "title=" Qq20141010144541.png "alt=" Wkiom1q3glpc0vjzaah8imenf3m577.jpg "/>

This article is from "Avatar" blog, please make sure to keep this source http://shamrock.blog.51cto.com/2079212/1562143

WebService Study notes-hello World

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.