Spring releases JAX-ws Service (i)

Source: Internet
Author: User
Tags wsdl

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)

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.