1) server-side development
Description: JDK is version 1.7
I. Create a project
Project Name: WEBS1
Ii. Creating an SEI (terminal)
A. Package Name: Cn.jbit.webs1.sei
B. Interface design
Interface Name: Hellosei.java
Interface content:
@WebService
Public interface Hellosei {
@WebMethod
public string SayHello (string name);
}
C. Implementing class Design
Implementation class Name: Helloseiimpl.java
Implementing the class content:
@WebService
public class Helloseiimpl implements Hellosei {
@Override
public string SayHello (string name) {
System.out.println ("SayHello");
Return "Hello" +name;
}
}
Iii. Publishing Services
A. Package Name: Cn.jbit.webs1.sei.test
B. Release
Class Name: Helloseitest.java
Class content:
public class Helloseitest {
public static void Main (string[] args) {
String address = "Http://192.168.8.116:8989/webs1/hello";
Endpoint.publish (Address, New Helloseiimpl ());
System.out.println ("release");
}
}
2) Client Development
I. Create a project
Project Name: WSClient
Ii. generating client code using the Wsimport.exe provided by the JDK
Wsimport-target 2.0-keep http://192.168.8.116:8989/webs1/hello?wsdl
Iii. Invoking the service
A. Package Name: Cn.jbit.webs1.sei.client
B. Call
Class Name: Clienttest.java
Class content:
public class Clienttest {
public static void Main (string[] args) {
Helloseiimplservice helloseiimplservice = new Helloseiimplservice ();
Helloseiimpl Helloseiimpl = Helloseiimplservice.gethelloseiimplport ();
String result = Helloseiimpl.sayhello ("Xiaoxiao");
SYSTEM.OUT.PRINTLN (result);
}
}
This article is from the "Yan" blog, please be sure to keep this source http://suyanzhu.blog.51cto.com/8050189/1564064
Create a Web service using the JDK