Announcement Announcement Module
Collapse
No announcement yet.
Premature end of file thrown from Axis SOAPPart Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Premature end of file thrown from Axis SOAPPart

    I have a simple message coming into the PayloadRootQNameEndpointMapping that is causing an odd exception when the mapping is trying to retrieve the payload source. I've tried it on a few recent versions of Tomcat.

    thanks!

    Jason Stiefel

    Here's the top of the trace:

    12:14:01,681 WARN SoapMessageDispatcher:288 - Endpoint invocation resulted in exception - responding with SOAP Fault
    org.springframework.ws.soap.saaj.SaajSoapEnvelopeE xception: Could not access envelope: org.xml.sax.SAXParseException: Premature end of file.; nested exception is javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
    Caused by:
    javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java :806)
    at org.springframework.ws.soap.saaj.Saaj11Implementat ion.getEnvelope(Saaj11Implementation.java:133)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etEnvelope(SaajSoapMessage.java:84)
    at org.springframework.ws.soap.AbstractSoapMessage.ge tSoapBody(AbstractSoapMessage.java:35)
    at org.springframework.ws.soap.AbstractSoapMessage.ge tPayloadSource(AbstractSoapMessage.java:49)
    at org.springframework.ws.server.endpoint.mapping.Pay loadRootQNameEndpointMapping.resolveQName(PayloadR ootQNameEndpointMapping.java:57)
    at org.springframework.ws.server.endpoint.mapping.Abs tractQNameEndpointMapping.getLookupKeyForMessage(A bstractQNameEndpointMapping.java:32)
    at org.springframework.ws.server.endpoint.mapping.Abs tractMapBasedEndpointMapping.getEndpointInternal(A bstractMapBasedEndpointMapping.java:105)
    at org.springframework.ws.server.endpoint.mapping.Abs tractEndpointMapping.getEndpoint(AbstractEndpointM apping.java:86)
    at org.springframework.ws.server.MessageDispatcher.ge tEndpoint(MessageDispatcher.java:221)
    at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:174)
    at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:144)
    Here's the message:
    <?xml version="1.0" encoding="UTF-8"?>

    <SOAP-ENV:Envelope

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"

    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Body>

    <GetCustomers xmlns="http://beip.barnhardt.net/schemas/crm">

    <ccnId xsi:type="xsd:int"></ccnId>

    <customerId xsi:type="xsd:int"></customerId>

    <locationId xsi:type="xsd:string"></locationId>

    </GetCustomers>

    </SOAP-ENV:Body>

    </SOAP-ENV:Envelope>
    And the XSD:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:crm="http://beip.barnhardt.net/schemas/crm"
    elementFormDefault="qualified"
    targetNamespace="http://beip.barnhardt.net/schemas/crm">

    <xs:complexType name="GetCustomersType">
    <xs:sequence>
    <xs:element name="ccnId" type="xs:int" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="customerId" type="xs:int" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="locationId" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Address">
    <xs:sequence>
    <xs:element name="line1" type="xs:string"></xs:element>
    <xs:element name="line2" type="xs:string"></xs:element>
    <xs:element name="line3" type="xs:string"></xs:element>
    <xs:element name="line4" type="xs:string"></xs:element>
    <xs:element name="line5" type="xs:string"></xs:element>
    <xs:element name="line6" type="xs:string"></xs:element>
    <xs:element name="city" type="xs:string"></xs:element>
    <xs:element name="state" type="xs:string"></xs:element>
    <xs:element name="zip" type="xs:string"></xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Credit">
    <xs:sequence>
    <xs:element name="hold" type="xs:string"></xs:element>
    <xs:element name="limit" type="xs:int"></xs:element>
    <xs:element name="terms" type="xs:string"></xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="CustomersType">
    <xs:sequence>
    <xs:element name="customer" type="crm:CustomerType" maxOccurs="unbounded" minOccurs="0"></xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="CustomerType">
    <xs:sequence>
    <xs:element name="location" type="crm:LocationType" maxOccurs="unbounded" minOccurs="0"></xs:element>
    </xs:sequence>
    <xs:attribute name="customerId" type="xs:int"></xs:attribute>
    </xs:complexType>

    <xs:element name="GetCustomersRequest" type="crm:GetCustomersType"></xs:element>
    <xs:element name="Customers" type="crm:CustomersType"></xs:element>

    <xs:complexType name="LocationType">
    <xs:sequence>
    <xs:element name="address" type="crm:Address"></xs:element>
    <xs:element name="credit" type="crm:Credit" maxOccurs="1" minOccurs="0"></xs:element>
    </xs:sequence>
    <xs:attribute name="ccnId" type="xs:int"></xs:attribute>
    <xs:attribute name="type">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:enumeration value="buyer"></xs:enumeration>
    <xs:enumeration value="ship"></xs:enumeration>
    <xs:enumeration value="ar"></xs:enumeration>
    <xs:enumeration value="enterprise"></xs:enumeration>
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="locationId" type="xs:string"></xs:attribute>
    </xs:complexType>

    <xs:element name="GetContactsRequest" type="crm:GetContactsType"></xs:element>

    <xs:complexType name="GetContactsType">
    <xs:sequence>
    <xs:element name="ccnId" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="customerId" type="xs:int" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="locationId" type="xs:int" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="contactId" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:element name="Contacts" type="crm:ContactsType"></xs:element>

    <xs:complexType name="ContactsType">
    <xs:sequence>
    <xs:element name="contact" type="crm:ContactType"
    maxOccurs="unbounded" minOccurs="0">
    </xs:element>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ContactType">
    <xs:sequence>
    <xs:element name="address" type="crm:Address" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="phone" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="phoneExt" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="name" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="email" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="fax" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    <xs:element name="faxExt" type="xs:string" maxOccurs="1" minOccurs="0"></xs:element>
    </xs:sequence>
    <xs:attribute name="locationId" type="xs:string"></xs:attribute>
    <xs:attribute name="customerId" type="xs:int"></xs:attribute>
    <xs:attribute name="ccnId" type="xs:int"></xs:attribute>
    </xs:complexType>


    <xs:element name="SaveOrUpdateContactRequest"
    type="crm:SaveOrUpdateContactType">
    </xs:element>

    <xs:complexType name="SaveOrUpdateContactType">
    <xs:sequence>
    <xs:element name="ccnId" type="xs:string" maxOccurs="1"
    minOccurs="0">
    </xs:element>
    <xs:element name="customerId" type="xs:int" maxOccurs="1"
    minOccurs="1">
    </xs:element>
    <xs:element name="locationId" type="xs:string" maxOccurs="1"
    minOccurs="1">
    </xs:element>
    <xs:element name="contactId" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="name" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="phone" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="phoneExt" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="title" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="fax" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="faxExt" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    <xs:element name="email" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>

  • #2
    Here's the bottom of the stacktrace where SAX is throwing up:

    Caused by: org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.axis.AxisFault.makeFault(AxisFault.java :129)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:543)
    at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java :804)
    ... 32 more
    Caused by: org.xml.sax.SAXParseException: Premature end of file.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalEr ror(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determin eDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:3 75)
    at org.apache.axis.encoding.DeserializationContextImp l.parse(DeserializationContextImpl.java:242)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:538)
    ... 33 more

    Comment


    • #3
      Weird, everything seems to be in order. Is that message dump from the client- or server-side?

      One possible solution would be to try and use the SAAJ reference implementation, rather than Axis's SAAJ. Let me know if that works.

      Comment


      • #4
        Arjen-

        When using the spring-ws-core maven dependency, whats the most straightforward way to override the dependency (in my local project) for saaj coming from spring-ws-core?

        Thanks for the assistance. I'm just getting started using Maven for more complex external dependencies.

        Jason Stiefel

        Comment


        • #5
          Well, spring-ws-core doesn't implement SAAJ, nor does it export the SAAJ implementation dependency. We don't want to force a particular implementation of SAAJ, since every app server has it's own impl.

          The easiest way to add it to your own project is to add:

          Code:
          <dependency>
              <groupId>com.sun.xml.messaging.saaj</groupId>
              <artifactId>saaj-impl</artifactId>
               <version>1.3</version>
          </dependency>
          That will give you SUN's reference implementation, version 1.3 (the latest).

          Comment


          • #6
            Ok, found the problem. I had another project that was causing xalan and/or xerces to come into my ws project through a second level transitive dependency.

            Hooray for the <exclusions> tag.

            thanks for the help Arjen! And spring-ws seems to be a great strategy!

            Jason Stiefel

            Comment


            • #7
              org.xml.sax.SAXParseException: Premature end of file.

              Hi,

              When I use JaxRpcProxyFactoryBean to consume the webservices using Axis 1.4, I don't see any issue. The moment I started using Spring-ws-rc1, I started getting the following exception. I would appreciate any help here. I tried playing around with jars and I did not see a change in the behaviour.

              org.springframework.ws.soap.saaj.SaajSoapEnvelopeE xception: Could not access envelope: org.xml.sax.SAXParseException: Premature end of file.; nested exception is javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
              Caused by: javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
              at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java :1005)
              at org.springframework.ws.soap.saaj.Saaj12Implementat ion.getEnvelope(Saaj12Implementation.java:140)
              at org.springframework.ws.soap.saaj.SaajSoapMessage.g etEnvelope(SaajSoapMessage.java:84)
              at org.springframework.ws.soap.AbstractSoapMessage.ge tSoapBody(AbstractSoapMessage.java:35)
              at org.springframework.ws.soap.AbstractSoapMessage.ha sFault(AbstractSoapMessage.java:55)
              at org.springframework.ws.soap.AbstractSoapMessage.ge tFaultReason(AbstractSoapMessage.java:60)
              at org.springframework.ws.client.core.SimpleFaultReso lver.resolveFault(SimpleFaultResolver.java:33)
              at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:367)
              at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 215)
              at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 203)
              at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 195)
              at gov.fda.furls.fmls.bus.impl.FmlsDocumentDrivenServ iceImpl.doCallFmlsService(FmlsDocumentDrivenServic eImpl.java:104)
              at gov.fda.furls.fmls.bus.impl.FmlsDocumentDrivenServ iceImpl.validateAddress(FmlsDocumentDrivenServiceI mpl.java:81)
              at gov.fda.furls.fmls.bus.impl.FmlsDocumentDrivenServ iceImplTest.testValidateAddress(FmlsDocumentDriven ServiceImplTest.java:40)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at junit.framework.TestCase.runTest(TestCase.java:154 )
              at junit.framework.TestCase.runBare(TestCase.java:127 )
              at org.springframework.test.ConditionalTestCase.runBa re(ConditionalTestCase.java:69)
              at junit.framework.TestResult$1.protect(TestResult.ja va: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 junit.framework.TestSuite.runTest(TestSuite.java:2 08)
              at junit.framework.TestSuite.run(TestSuite.java:203)
              at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:128)
              at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
              at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
              Caused by: org.xml.sax.SAXParseException: Premature end of file.
              at org.apache.axis.AxisFault.makeFault(AxisFault.java :101)
              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:701)
              at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java :1003)
              ... 32 more
              Caused by: org.xml.sax.SAXParseException: Premature end of file.
              at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Unknown Source)
              at org.apache.xerces.util.ErrorHandlerWrapper.fatalEr ror(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
              at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
              at org.apache.xerces.impl.XMLVersionDetector.determin eDocVersion(Unknown Source)
              at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
              at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
              at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
              at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
              at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser .parse(Unknown Source)
              at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
              at org.apache.axis.encoding.DeserializationContext.pa rse(DeserializationContext.java:227)
              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:696)
              ... 33 more

              Comment


              • #8
                Perhaps you can use Apache TcpMon to determine what is sent across the wire? http://ws.apache.org/axis/java/user-...PMonitorTcpmon

                Comment


                • #9
                  I'm having a similar problem, and I've been struggling for a while, now.

                  I'm using Castor marshalling.

                  This is the error I get (similar to the Original Poster's):

                  Code:
                  javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
                          at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java:1005)
                          at org.apache.axis.Message.getSOAPBody(Message.java:555)
                          at org.springframework.ws.soap.saaj.Saaj12Implementation.getEnvelope(Saaj12Implementation.java:144)
                          at org.springframework.ws.soap.saaj.SaajSoapMessage.getEnvelope(SaajSoapMessage.java:81)
                          at org.springframework.ws.soap.AbstractSoapMessage.getSoapBody(AbstractSoapMessage.java:35)
                          at org.springframework.ws.soap.AbstractSoapMessage.getPayloadSource(AbstractSoapMessage.java:45)
                          at org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping.resolveQName(PayloadRootQNameEndpointMapping.java:55)
                          at org.springframework.ws.server.endpoint.mapping.AbstractQNameEndpointMapping.getLookupKeyForMessage(AbstractQNameEndpointMapping.java:32)
                          at org.springframework.ws.server.endpoint.mapping.AbstractMapBasedEndpointMapping.getEndpointInternal(AbstractMapBasedEndpointMapping.java:105)
                          at org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping.getEndpoint(AbstractEndpointMapping.java:82)
                          at org.springframework.ws.server.MessageDispatcher.getEndpoint(MessageDispatcher.java:237)
                          at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:190)
                          at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:157)
                          at org.springframework.ws.transport.support.WebServiceMessageReceiverObj
                          ....(other lines skipped)
                  Caused by: org.xml.sax.SAXParseException: Premature end of file.
                          at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
                          at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
                          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                          at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
                          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
                          at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
                          at org.apache.axis.encoding.DeserializationContext.parse(Deserialization Context.java:227)
                          at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
                          ... 40 more
                  I'm using a local test client, and using a request filter, I see that the following information is arriving:

                  Code:
                  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmln
                  s:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSc
                  hema-instance">
                   <soapenv:Body>
                    <ns1:AddUserRequest xmlns:ns1="http://mycompany.com/messages">
                     <ns1:msisdn>XXXX</ns1:msisdn>
                     <ns1:email>XXXX</ns1:email>
                     <ns1:password>XXXX</ns1:password>
                     <ns1:login xsi:nil="true"/>
                     <ns1:server xsi:nil="true"/>
                    </ns1:AddUserRequest>
                   </soapenv:Body>
                  </soapenv:Envelope>

                  Any suggestions on how to continue investigating?
                  If I wanted to change the SAAJ implementation (as suggested earlier), how can I do it without using maven?

                  Thanks in advance.

                  Comment


                  • #10
                    Well, the suggestion that seemed to work above was to make sure which version of xalan/xerces you are using. Make sure they are pretty recent (i.e. xerces 2.8.1 and xalan 2.7.0).

                    Comment


                    • #11
                      I'm having the same problem with my app, the Echo sample works fine though.

                      Xerces/Xalan doesn't seem to be the problem as I have the versions Arjen mentioned above.

                      TcpMon shows the my content in the POST, I'm not sure how it got into this state.

                      Comment


                      • #12
                        Turns out there is a bug in Spring-WS when using Axis1's SAAJ implementation. See http://opensource.atlassian.com/proj...browse/SWS-150. It will be fixed shortly.

                        Comment


                        • #13
                          Exactly what I was going to say :P
                          Jumping to saaj 1.3 fixed it for me as well though.

                          Comment

                          Working...
                          X