3

I am sending POST request to UPS paperless document api for upload user created form but i am getting The XML document is not well formed My Request Message is.

<?xml version=\"1.0\"?>
<UPSSecurity>
  <UsernameToken>
    <Username>******</Username>
    <Password>******</Password>
  </UsernameToken>
  <ServiceAccessToken>
    <AccessLicenseNumber>*************</AccessLicenseNumber>
  </ServiceAccessToken>
</UPSSecurity>

<?xml version=\"1.0\"?>
<UploadRequest>
<Request>
<TransactionReference>
  <CustomerContext></CustomerContext>
</TransactionReference>
</Request>
<ShipperNumber>??????</ShipperNumber>
<UserCreatedForm>
  <UserCreatedFormFileName>Sample Test File</UserCreatedFormFileName>
  <UserCreatedFormFile>SGVsbG8gQW5rdXI=</UserCreatedFormFile>
  <UserCreatedFormFileFormat>txt</UserCreatedFormFileFormat>
  <UserCreatedFormDocumentType>011</UserCreatedFormDocumentType>
</UserCreatedForm>
</UploadRequest>

After posting this request with REST I am getting this response..

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<soapenv:Fault>
<faultcode>Client</faultcode>
<faultstring>An exception has been raised as a result of client data.</faultstring>
<detail>
<err:Errors xmlns:err="http://www.ups.com/schema/xpci/1.0/error">
<err:ErrorDetail>
<err:Severity>Hard</err:Severity>
<err:PrimaryErrorCode>
<err:Code>10001</err:Code>
<err:Description>The XML document is not well formed</err:Description>
<err:Digest>XML Declaration not well-formed
org.apache.xmlbeans.impl.piccolo.io.FileFormatException: XML Declaration not well-formed
at org.apache.xmlbeans.impl.piccolo.xml.XMLDeclParser.parse(XMLDeclParser.java:907)
at org.apache.xmlbeans.impl.piccolo.xml.XMLInputReader.parseXMLDeclaration(XMLInputReader.java:56)
at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.processXMLDecl(XMLStreamReader.java:687)
at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.reset(XMLStreamReader.java:119)
at org.apache.xmlbeans.impl.piccolo.xml.DocumentEntity.open(DocumentEntity.java:94)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.reset(PiccoloLexer.java:982)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:709)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3456)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:663)
at com.ups.uxf.process.ServiceRequest.setMessage(ServiceRequest.java:545)
at com.ups.uxf.servlet.UXFServlet._doPost(UXFServlet.java:185)
at com.ups.wsf.servlet.WSFServlet.doPost(WSFServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:845)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:75)
at com.ups.webappcommon.filter.AkamaiFilter.doFilter(AkamaiFilter.java:33)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3262)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2171)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2075)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1514)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
</err:Digest>
</err:PrimaryErrorCode>
<err:Location/>
</err:ErrorDetail>
</err:Errors>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

I am using RESTClient. Please Help. Thanks in advance.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Ankur
  • 893
  • 3
  • 12
  • 29
  • 1
    Looks like you're mixing up SOAP and REST. The first example contains 2 documents, which would always be invalid. The second SOAP example is what I'd expect from posting REST XML to SOAP. – William Walseth Nov 27 '14 at 14:38
  • 1
    Did you resolve your problem? – kjhughes Nov 28 '14 at 14:47
  • No..I updated My question.. – Ankur Nov 28 '14 at 14:53
  • 1
    Your update is not a reasonable refinement; you *completely* changed the question. I've rolled back your too-broad change. Please finish here and create a new question about your new problem if necessary. Thanks. – kjhughes Nov 28 '14 at 17:39

2 Answers2

2

Your request message is not well-formed because:

  1. The first XML declaration is incorrect.

    Remedy: Delete the \ characters.

  2. The second XML declaration is incorrect because it also has \ characters and because there can be at most one XML declaration and, if it appears, it must be at the very top of an XML document.

    Remedy: Delete the second XML declaration.

  3. The request has two root elements.

    Remedy: Delete one of them, or wrap them both in a single root element.

Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Hello, im having the same problem right now ... I cant delete the root elements because the UPS Api Documentation wants them to be there as Ankur showed in his question. Maybe I should first send the first XML with login and then send the rest? Would it help? Thanks – Zdeněk Bednařík Apr 06 '17 at 08:43
  • @ZdeněkBednařík: Please post a new question that includes a [mcve] particular to your problem. Thanks. – kjhughes Apr 06 '17 at 12:28
  • I have the same question as the one here ... but it has no solution. Your answer looks interesting thats why im asking you why should we delete the second xml declaration when the UPS wants two declarations to be present (according to documentation) – Zdeněk Bednařík Apr 06 '17 at 12:36
  • Any documentation that says that two XML declarations should be present in the same XML file is completely and utterly wrong because it would render the XML not well-formed and therefore not meeting the standards for being XML at all. – kjhughes Apr 06 '17 at 12:38
  • This answer is completely correct, and could possibly help your problem as well, but if you need further help, post a new question with the particulars of your case. – kjhughes Apr 06 '17 at 12:40
  • So if the documentation says that it needs two ?xml version="1.0"? then i should send first and then send the second one? – Zdeněk Bednařík Apr 06 '17 at 12:44
  • @ZdeněkBednařík: Again, please post a new question that includes a [mcve] example particular to your problem, including a link to the documentation that you reference. I will not be continuing this conversation further in comments. Thanks. – kjhughes Apr 06 '17 at 12:46
0

Try to include UPSSecurity in soap header and UploadRequest in soap body.

syam
  • 799
  • 1
  • 12
  • 30
del
  • 1