私はクライアントからサービスサーバーへのメッセージとしてオブジェクトを使用しています。 サービスが見つかるようにエンドポイントをどのように設定する必要がありますか? @PayloadRootは、私は、XMLスキーマを使用していないので、ここでunfittingようだが、 @XmlRootElement(すなわちストリート)@PayloadRootの値はオブジェクトを使用し、スキーマXMLではなく
私のコードで注釈されるオブジェクト:
春-WS-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
<context:component-scan base-package="com.coral.project.endpoints"/>
<sws:annotation-driven />
<sws:dynamic-wsdl id="test" portTypeName="TestCase" locationUri="/testService/"
targetNamespace="http://www.example.org/schemasDef/test/definitions">
<sws:xsd location="/WEB-INF/schemasDef/test.xsd"/>
</sws:dynamic-wsdl>
<bean id="springWSClient" class="com.coral.project.endpoints.SpringWSClient">
<property name="defaultUri" value="http://localhost:8080/parking/springServices/testService/"/>
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
</bean>
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="com.coral.project.entity.Street"/>
</oxm:jaxb2-marshaller>
</beans>
クライアント:
public class SpringWSClient extends WebServiceGatewaySupport {
public void getSum() throws SOAPException, IOException, TransformerException {
StreetDao streetDao = SpringUtils.getBean(StreetDao.class);
Street street = streetDao.findById(1);
getWebServiceTemplate().marshalSendAndReceive(street);
}
}
エンドポイント:
@Endpoint
public class SpringWsEndpoint {
@Inject
private SpringWebService springWebService;
@PayloadRoot(localPart = "street", namespace = "http://blahblah")
@ResponsePayload
public Element handleTestRequest(@RequestPayload SAXSource testRequest) throws Exception {
String fisrt = firstNum.valueOf(testRequest);
String second = secondNum.valueOf(testRequest);
String sum = springWebService.sum(Integer.parseInt(fisrt), Integer.parseInt(second)).toString();
Element responseElement = new Element("TestRequest");
Element sumElement = new Element("sum");
sumElement.setText(sum);
responseElement.setContent(sumElement);
return responseElement;
}
}