I have two problems and they both relate to parsing xml, it looks like my message body is being changed when it reaches the client and thereafter the parsing fails. They are probably one problem showing up in two ways.
I have this message generated from an external server (ie I have no control over this server).
I can manually strip the soap envelope from this message an unmarshall it into objects generated with xjc. But when it arrives at my client I see this:Code:<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <m:getCustomerResponse xmlns:m="http://www.xxx.co.nz/EAI/V1_22_1" xmlns:eai="http://www.xxx.co.nz/EAI/V1_22_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xxx.co.nz/EAI/V1_22_1 EAI_V1_22_1.xsd" > <getCustomerResponseResult xsi:type="m:customer"> <!-- CONTEXT:customer:CONTEXT --> <partyRoleCategory> ...
My WS client is really simple. No unmarshalling, just a template wired like this:Code:Exception: Transformation error: Undeclared namespace in :getCustomerResponseResult; nested exception is net.sf.saxon.trans.XPathException: Undeclared namespace in :getCustomerResponseResult Cause: Transformation error: Undeclared namespace in :getCustomerResponseResult; nested exception is net.sf.saxon.trans.XPathException: Undeclared namespace in :getCustomerResponseResult at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.getCustomer(DSMCRMDAO.java:57) at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.loadCustomer(DSMCRMDAO.java:117) at nz.co.xxx.dsm.crm.dao.DSMCRMDAOTest.testloadCustomer(DSMCRMDAOTest.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.springframework.ws.client.WebServiceTransformerException: Transformation error: Undeclared namespace in :getCustomerResponseResult; nested exception is net.sf.saxon.trans.XPathException: Undeclared namespace in :getCustomerResponseResult at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:430) at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:358) at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:304) at nz.co.xxx.dsm.eai.WebServiceHelper.send(WebServiceHelper.java:244) at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.getCustomer(DSMCRMDAO.java:48) ... 19 more
And a call like this:Code:<bean id="webserviceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> <property name="defaultUri" value="http://localhost:8100/SunriseWSEndpoint/services" /> </bean>
I've seen other topics here referring to the xml libraries so the ones I'm using are :Code:m_webServiceTemplate.sendSourceAndReceiveToResult(m_url.toString(),transformedRequest,webServiceMessageCallback,result);
saxon-9.0.0
xalan-2.7.0
xercesImpl-2.8.1
xmlapis-2.0.2
spring-ws-core-1.0.2
spring-ws-core-tiger-1.0.2
As an experiment I modified the message I get (which I cannot do in real life) to add xmlns="http://www.xxx.co.nz/EAI/V1_22_1" to the m:getCustomerResponse tag. This got the message through the above problem but it was changed in the process so that it now looks like:
And when I try to unmarshal this it says:Code:<?xml version="1.0" encoding="UTF-8"?> <m:getCustomerResponse xmlns:m="http://www.xxx.co.nz/EAI/V1_22_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xsi:schemaLocation="http://www.xxx.co.nz/EAI/V1_22_1 EAI_V1_22_1.xsd"> <getCustomerResponseResult xmlns="http://www.xxx.co.nz/EAI/V1_22_1" xsi:type="m:customer"> <partyRoleCategory> <code>customer subtype</code> </partyRoleCategory>
The eai namespace definition has been removed and there default namespace on the getCustomerResponseResult is not working, I think it needs to be on the tag above, where it was in the message, ie before it was mysteriously moved.Code:Exception: org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'getCustomerResponseResult'. One of '{"":getCustomerResponseResult}' is expected.] Cause: org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'getCustomerResponseResult'. One of '{"":getCustomerResponseResult}' is expected.] at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.getCustomer(DSMCRMDAO.java:57) at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.loadCustomer(DSMCRMDAO.java:117) at nz.co.xxx.dsm.crm.dao.DSMCRMDAOTest.testloadCustomer(DSMCRMDAOTest.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.RuntimeException: org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'getCustomerResponseResult'. One of '{"":getCustomerResponseResult}' is expected.] at nz.co.xxx.dsm.eai.WebServiceHelper.unmarshal(WebServiceHelper.java:166) at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.getCustomer(DSMCRMDAO.java:52) ... 19 more Caused by: org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'getCustomerResponseResult'. One of '{"":getCustomerResponseResult}' is expected.] at org.springframework.oxm.jaxb.JaxbUtils.convertJaxbException(JaxbUtils.java:75) at org.springframework.oxm.jaxb.AbstractJaxbMarshaller.convertJaxbException(AbstractJaxbMarshaller.java:143) at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:399) at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:383) at nz.co.xxx.dsm.eai.WebServiceHelper.unmarshal(WebServiceHelper.java:161) ... 20 more
Thanks for any help.


Reply With Quote