官方帮助手册:http://docs.spring.io/spring-ws/site/reference/html/tutorial.html
接着《Spring-WS(一)-环境搭建》所搭建的服务,运行项目访问地址:
http://localhost:8080/Spring-WS-Demo-01/service/UserService.wsdl;SpringWS会根据我们定义的Schema来生成wsdl。那这篇文章就继续开展我们的后台处理逻辑,究竟SpringWS对于Web Service请求是如何处理的?过于细节的东西就不详细说了,后续的博客都会提到,现在先把大概的脉络搭建起来。
一、根据SpringWS生成的WSDL,服务端根据接口来定义AddRequest.java,AddResponse.java等文件,但是这些工作是可以交给MyEclipse去生成的,可以通过NEW->“Web Service Client”,不清楚的可以百度。虽然MyEclipse会自动帮我们生成很多文件,但是用到的就那几个,分别是AddRequest,AddResponse,GetUserByUserNameRequest,GetUserByUserNameResponse,User 如下:
package ws.user.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import ws.user.endpoint.UserServiceEndpoint;
/**
* <p>
* Java class for anonymous complex type.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <all>
* <element ref="{http://localhost/ws/UserService}User"/>
* </all>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
})
@XmlRootElement(name = "AddRequest", namespace=UserServiceEndpoint.USER_SERVICE_NAMESPACE)
public class AddRequest {
@XmlElement(name = "User", namespace = "http://localhost/ws/UserService", required = true)
protected User user;
/**
* Gets the value of the user property.
*
* @return possible object is {@link User }
*
*/
public User getUser() {
return user;
}
/**
* Sets the value of the user property.
*
* @param value
* allowed object is {@link User }
*
*/
public void setUser(User value) {
this.user = value;
}
}
package ws.user.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import ws.user.endpoint.UserServiceEndpoint;
/**
* <p>
* Java class for anonymous complex type.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
*
* <pre>
* <complexType>
* <compl