我正在向UPS无纸文档api发送POST请求以上传用户创建的表单但我得到 XML文档格式不正确 我的请求消息。
<?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>
用REST发布此请求后 我收到此回复..
<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>
我正在使用RESTClient。 请帮忙。提前致谢。
答案 0 :(得分:2)
第一个XML声明不正确。
补救措施:删除\
个字符。
第二个XML声明不正确,因为它还有\
个字符,因为there can be at most one XML declaration and, if it appears, it must be at the very top of an XML document。
补救措施:删除第二个XML声明。
请求有两个根元素。
补救措施:删除其中一个,或将它们都包装在一个根元素中。
答案 1 :(得分:0)
尝试在肥皂标题中包含UPSSecurity
,在肥皂体中添加UploadRequest
。