1.maven Dependency:
<dependency> <groupId>org.springframework.ws</groupId> <artifactId> Spring-ws-core</artifactid> <version>2.1.4.RELEASE</version></dependency>< dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> <version>1.1</version></dependency><dependency> <groupid>jaxen</groupid > <artifactId>jaxen</artifactId> <version>1.1.6</version></dependency >
2, write the need to publish the JavaBean
Import Javax.jws.WebMethod; Import Javax.jws.WebService; Import = "MyService")publicclass holidayendpoint { @WebMethod Public string Say (string name) { return "Hello," +name; }}
3. Configure Web. xml:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> Classpath:beans.xml</param-value></context-param><listener> <listener-class >org.springframework.web.context.contextloaderlistener</listener-class></listener>
4. Spring configuration file Beans.xml
class= "Org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter" > <property name= " BaseAddress "value=" http://localhost:8081/services/"/> </bean>
Server: Tomcat port number: 8081
wsdl:http://localhost:8081/services/myservice?wsdl
Notes and Notes
(1), Access WebService deployment descriptor via HTTP://LOCALHOST:8081/SERVICES/MYSERVICE?WSDL
There are also auto-generated xsd:http://localhost:8081/services/myservice?xsd=1.
(2), @SOAPBinding (parameterstyle=parameterstyle.wrapped)
Must be added, otherwise it will be an error; Also, if the published method has only one parameter, you can use @soapbinding (parameterstyle=parameterstyle.bare).
(3), @WebService (serviceName = "MyService") the service name is consistent with the bean configured by spring.
(4), WebService port settings do not like the server, this is very important or the server application conflicts with the WebService service will produce a HTTP404 error.
Spring releases JAX-ws Service (i)