Create a Web service using the JDK

Source: Internet
Author: User

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

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.