We've recently run into an exception with unmarshalling when using the Jaxb2Marshaller with contextPath set (using ObjectFactory). This only happens for methods where the Endpoint method uses XPathParam & MarshallingSource (Spring WS 1.5.9):
Here's the client method being used:Code:@SoapAction(value = WebServiceConstants.SOAPACTIONS.SOME_METHOD) public Source getSomeObject(@XPathParam("/fs:someIdRequest") String someId) { SomeModelObject obj = someService.getSomeObject(Long.parseLong(someId)); return new MarshallingSource(marshaller, obj); }
The following Exception is thrown by the client method:Code:@Override public SomeObject getSomeObject(long someId) { final String request = "<fs:someIdRequest xmlns:fs=\"" + WebServiceConstants.SOAPACTIONS.FOUNDATIONS_NAMESPACE + "\">" + someId + "</fs:someIdRequest>"; return ((SomeModelObject) webServiceTemplate.sendSourceAndReceive(new StringSource(request), new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage webServiceMessage) throws IOException, TransformerException { ((SoapMessage) webServiceMessage).setSoapAction(WebServiceConstants.SOAPACTIONS.SOME_METHOD); } }, marshallableSourceExtractor)); }
Other methods that use @SoapAction without @XPathParam work fine, and when we change the Jaxb2Marshaller to use "classesToBeBound" instead of "contextPath" the above method works fine too. However, we'd like to use ObjectFactory for maintainability purposes.Code:java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to com.somecompany.someapp.model.SomeObject at com.somecompany.someapp.ws.service.impl.WSServiceImpl.getSomeObject(WSServiceImpl.java:52)
Things that I've checked:
- The ObjectFactory does have a "create" method for the model object that is throwing the Exception.
- The model object does have an XmlRootElement annotation.
Does anyone have any idea what might be causing the problem? Thanks in advance!


Reply With Quote