-
May 31st, 2011, 11:38 AM
#1
@PayloadRoot value when using Objects and not schema xml
Hello. I'm using Objects as messages from client to service server. How should the endpoint be configured so that the service would be found? @PayloadRoot seems unfitting here because i don't use xml schema but Objects annotated with @XmlRootElement (i.e. Street)
I'm using spring-ws 2.0.1
my code:
the spring-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/schem...-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schem...rvices-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-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>
the client:
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(stre et);
}
}
the endpoint:
@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;
}
}
-
Jun 1st, 2011, 04:24 AM
#2
Solved it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules