Results 1 to 8 of 8

Thread: incoming message gives parse errors

  1. #1
    Join Date
    Aug 2007
    Posts
    12

    Unhappy incoming message gives parse errors

    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).
    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>
    ...
    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:
    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
    My WS client is really simple. No unmarshalling, just a template wired like this:
    Code:
    	<bean id="webserviceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    		<property name="defaultUri" value="http://localhost:8100/SunriseWSEndpoint/services" />
    	</bean>
    And a call like this:
    Code:
    m_webServiceTemplate.sendSourceAndReceiveToResult(m_url.toString(),transformedRequest,webServiceMessageCallback,result);
    I've seen other topics here referring to the xml libraries so the ones I'm using are :
    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:
    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>
    And when I try to unmarshal this it says:
    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
    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.

    Thanks for any help.

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Could you try to use 1.5 RC1? I fixed some SAXON related issues in that 1.5 M2 and higher (http://jira.springframework.org/browse/SWS-265). These will also be part of the forthcoming 1.0.4, which will be out after 1.5 has been released.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Aug 2007
    Posts
    12

    Unhappy Retried under 1.5.0-m2

    Thanks for the help.

    I switched to the following libraries:
    spring-ws-core-1.5.0-m2
    spring-oxm-1.5.0-m2
    spring-oxm-tiger-1.5.0-m2

    and I am still running
    saxon-9.0.0
    xalan-2.7.0
    xercesImpl-2.8.1
    xmlapis-2.0.2

    I'm still getting problems. I've changed the system around a bit so the problem is not quite the same but I think it is the same thing in disguise.

    I now have a simple http client that grabs the xml and uses JAXB to unmarshal it. That works fine, but we lose the advantages of having the soap headers constructed flexibly. However I can get a message like this:

    Code:
          <soapenv:Envelope 
          	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
          	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
          	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <soapenv:Header>
                <applicationContext soapenv:mustUnderstand="0"/>
             </soapenv:Header>
             <soapenv:Body>
                <ns2:getCustomer xmlns:ns2="http://www.xxx.co.nz/EAI/V1_22_1">
                   <customerKey>
                      <primaryKey>1231523</primaryKey>
                   </customerKey>
                   <objectNames>
    ....
    which works with my http/xml/jxb code but fails when I pass it through my Spring-ws SOAP client. The error is
    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 
    ...
    Caused by: net.sf.saxon.trans.XPathException: Undeclared namespace in :getCustomerResponseResult
    	at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:187)
    	at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145)
    	at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228)
    	at net.sf.saxon.dom.DOMSender.sendElement(DOMSender.java:122)
    	at net.sf.saxon.dom.DOMSender.send(DOMSender.java:93)
    	at net.sf.saxon.dom.DOMObjectModel.sendSource(DOMObjectModel.java:112)
    	at net.sf.saxon.event.Sender.send(Sender.java:216)
    	at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:29)
    	at org.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:339)
    	at org.springframework.ws.client.core.WebServiceTemplate$SourceExtractorMessageExtractor.extractData(WebServiceTemplate.java:696)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492)
    	... 27 more
    Should I be using a different saxon library?

    Thanks
    Roger

  4. #4
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Saxon and Xalan are both transformation engines, so you don't need both. Either will do.

    As for the error: what does the response look like? You can use a tool like tcpmon (https://tcpmon.dev.java.net/) to find out...
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #5
    Join Date
    Aug 2007
    Posts
    12

    Unhappy

    I'm not explaining the problem well enough.
    The sample message is what I got from tcpmon.
    When it reaches the client it fails with the stack dump.
    I'm not trying to get the client to unmarshal it, I just want the payload as an InputSource object. My client does this:
    Code:
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Result result = new StreamResult(out);
                m_webServiceTemplate.sendSourceAndReceiveToResult(m_url.toString(),transformedRequest,webServiceMessageCallback,result);
            return new InputSource(new StringReader(out.toString()));
    So your point about the two transformation engines is surely correct, but possibly not relevant to the problem? I put the saxon one in there because I got an early error message telling me I had to have saxon9-dom on my classpath. Xalan was already there.
    Thanks

  6. #6
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Ok, if that's the message you get, then I don't understand why the parser is complaining about getCustomerResponseResult, since I don't see that element in your sample message.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7
    Join Date
    Aug 2007
    Posts
    12

    Unhappy I'll try again...

    I need to be more careful, sorry.

    Here is the message I am receiving at the client, so this is a response from the server to a valid message from the client (trimmed for brevity)
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
          <SOAP-ENV:Envelope 
          	xmlns:ns2="http://www.xxx.co.nz/EAI/UMTS_ICMSAdapter" 
          	xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
          	xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
          	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
          	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          	xsi:schemaLocation="http://www.xxx.co.nz/EAI/UMTS_ICMSAdapter UMTS_ICMSAdapter.xsd">
             <SOAP-ENV:Body>
                <ns2:getCustomerResponse>
                   <getCustomerResponseResult>
                      <partyRoleCategory>
                         <code>customer subtype</code>
    This is the error I get:
    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
    ...
    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 com.salestech.dsm.eai.WebTransportSOAP.send(WebTransportSOAP.java:69)
    	at com.salestech.dsm.eai.WebServiceHelperImpl.send(WebServiceHelperImpl.java:221)
    	at nz.co.xxx.dsm.crm.dao.DSMCRMDAO.getCustomer(DSMCRMDAO.java:99)
    	... 21 more
    Caused by: net.sf.saxon.trans.XPathException: Undeclared namespace in :getCustomerResponseResult
    	at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:187)
    	at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:145)
    	at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:228)
    	at net.sf.saxon.dom.DOMSender.sendElement(DOMSender.java:122)
    	at net.sf.saxon.dom.DOMSender.send(DOMSender.java:93)
    	at net.sf.saxon.dom.DOMObjectModel.sendSource(DOMObjectModel.java:112)
    	at net.sf.saxon.event.Sender.send(Sender.java:216)
    	at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:29)
    	at org.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:308)
    	at org.springframework.ws.client.core.WebServiceTemplate$SourceExtractorMessageExtractor.extractData(WebServiceTemplate.java:589)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:416)
    This time the tag in the error message matches the tag in the response.
    I think I just need to know what must change in the message to make it work. I have tried several variations such as adding a
    Code:
    xmlns="http://www.xxx.co.nz/EAI/UMTS_ICMSAdapter"
    to various places. So far that gives me other errors. I do have limited ability to change the message, though, because it comes from an external source.

    Thanks for your help

  8. #8
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Iit looks like the getCustomerResponseResult has no namespace: only the getCustomerResponse has prefix ns2 and namespace http://www.xxx.co.nz/EAI/UMTS_ICMSAdapter. I think that's what Saxon is complaining about.

    Since you stated before that you cannot change the server-side message, I can't think of anything to help. You could try getting rid of Saxon altogether, and see whether Xalan gets you further.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •