Yiyun development team if you want to develop Web services under Tomcat, download jaxws.zip,: example...
I. deployment before development
If you want to develop Web services under tomcat, then you need to download jaxws.zip,: http://jax-ws.java.net/2.2.5/
To create a web service, deploy it in the following Directory:
Medium:
Place the jar package in jaxws.zip in lib;
Classes stores the SIB and SEI of the web service (if it is style = document, the wsgen tool is also required to generate the type );
Sun-jaxws.xml is a web service-specific configuration file;
Here, WEBROOT is assumed to be the ws folder;
2. development steps
1. write SEI
Package org. xiazdong. ws;
Import javax. jws .*;
@ WebService
Public interface TempConvert {
@ WebMethod int f2c (int I );
@ WebMethod int c2f (int I );
}
2. compile SIB
Package org. xiazdong. ws;
Import javax. jws .*;
@ WebService (endpointInterface = "org. xiazdong. ws. TempConvert ")
Public class TempConvertImpl implements TempConvert {
Public int f2c (int I ){
Return I-5;
}
Public int c2f (int I ){
Return I + 5;
}
}
3. Compile the above two files;
Javac-d. *. java
4. generate types using the wsgen tool
Wsgen-cp. org. xiazdong. ws. TempConvertImpl
5. compile web. xml
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
Version = "2.5">
Com. sun. xml. ws. transport. http. servlet. WSServletContextListener
TimeServerWS
Com. sun. xml. ws. transport. http. servlet. WSServlet
TimeServerWS
/Ws
6. write sun-jaxws.xml
Name = "TimeServerWS"
Implementation = "org. xiazdong. ws. TempConvertImpl"
Url-pattern = "/ws"/>
7. Arrange these files according to the directory layout;
Finally, enter http: // localhost: 8080/ws? Check whether the wsdl exists. If yes, the deployment is correct;
3. call services
1. use the wsimport tool
Wsimport-keep-p client http: // localhost: 8080/ws? Wsdl
Generate service code;
2. Compile the call client www.2cto.com
Import client .*;
Public class TimeClient {
Public static void main (String args []) {
TempConvertImplService service = new TempConvertImplService ();
TempConvert c = service. getTempConvertImplPort ();
System. out. println (c. f2C (5 ));
}
}
From xiaozdong