我已配置了我的网络服务。
申请案文:
<sws:annotation-driven />
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" >
<property name="interceptors">
<list>
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</list>
</property>
注:如果申请提出,拦截器就装上了开端,但却没有写任何东西。
我有一类人服务,其方法是增加个人服务。 一切工程,如果是使用org.dom4j。 作为方法参数的要素;
@Endpoint
public class PersonServiceImpl {
@PayloadRoot(namespace = "http://www.example.org/person/schema", localPart = "AddPersonRequest")
@ResponsePayload
public AddPersonRequest addPersonRequest(@RequestPayload Element element) {
System.out.println(element.asXML());
Person response = new Person();
response.setId(2);
response.setFirstName("Mad");
response.setLastName("Mike");
return response;
}
}
但是,如果改变我的方法参数,如下文所示(应当使用春季-湿重的自动标识),则请求书。 (JAXB2正在上班)。
The Person-class is annotated with @XMLType and @XMLRootElement.
注:对工作进行罚款。
@Endpoint
public class PersonServiceImpl {
@PayloadRoot(namespace = "http://www.example.org/person/schema", localPart = "AddPersonRequest")
@ResponsePayload
public AddPersonRequest addPersonRequest(@RequestPayload Person request, SoapHeader header) {
System.out.println(header.getName());
System.out.println(request.getFirstName());
Person response = new Person();
response.setId(2);
response.setFirstName("Mad");
response.setLastName("Mike");
return response;
}
}
Person.java:
@XmlType
@XmlRootElement(namespace="http://www.example.org/person/schema", name="Person")
public class Person implements Serializable {
private int id;
private String firstName;
private String lastName;
@XmlElement
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@XmlElement
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@XmlAttribute
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
通过肥皂倡议发出的测试请求(由湿租赁产生):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.example.org/person/schema">
<soapenv:Header/>
<soapenv:Body>
<sch:AddPersonRequest>
<sch:Person sch:Id="1">
<sch:FirstName>firstname</sch:FirstName>
<sch:LastName>lastname</sch:LastName>
</sch:Person>
</sch:AddPersonRequest>
</soapenv:Body>
</soapenv:Envelope>