Soap response, not well formed XML, no XOP parts located, using WSE
Asked Answered
E

3

5

I am consuming a web service in which I send off a request with an attachment and we receive a response from the server with various information. I have documented some problems with getting the request together in another question Adding an attachment to SOAP request but this bit has been resolved and now another problem has cropped up on the response.

We receive the response ok but an error is thrown stating:

Response is not well-formed XML.

The InnerException is:

WSE1608: No XOP parts were located in the stream for the specified content-id: <rootpart*[email protected]>

The xml that is returned looks like:

--uuid:36875c60-630c-4e23-9e74-f9a9c7547fc7
Content-Type: application/xop+xml;charset=utf-8;type="text/xml";
Content-ID: <rootpart*[email protected]>
content-transfer-encoding: binary

  <?xml version="1.0" encoding="utf-8"?>
  <soapenv:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <payloadManifest xmlns="http://(namespace)">
        <manifest contentID="content0" element="ProcessAttachment" namespaceURI="http://(namespace)" version="2.01"/>
      </payloadManifest>
    </soapenv:Header>
    <soapenv:Body>
      <tran:ProcessMessageResponse xmlns="http://(namespace)" xmlns:ns2="http://(ns2Namespace)" xmlns:ns3="http://(ns3Namespace)" xmlns:tran="http://(tranNamespace)">
        <tran:payload>
          <tran:content id="content0">
            <s:ShowServiceProcessingAdvisory xmlns:s="http://(sNamespace)">
              <s:ApplicationArea>
                <s:Sender>
                  <s:Component>Global Warranty Management</s:Component>
                  <s:Task>ShowAttachments</s:Task>
                  <s:CreatorNameCode>Creator</s:CreatorNameCode>
                  <s:SenderNameCode>GM</s:SenderNameCode>
                </s:Sender>
                <s:CreationDateTime>2012-01-10T12:58:27Z</s:CreationDateTime>
                <s:Destination>
                  <s:DestinationNameCode>XX</s:DestinationNameCode>
                  <s:DealerNumber>234567</s:DealerNumber>
                  <s:DealerCountry>US</s:DealerCountry>
                </s:Destination>
              </s:ApplicationArea>
              <s:DataArea>
                <s:Show/>
                <s:ServiceProcessingAdvisory>
                  <s:Header>
                    <s:SecondaryDealerNumber>253909</s:SecondaryDealerNumber>
                    <s:Disposition>
                      <s:RepairOrder>
                        <s:WarrantyClaim xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:WarrantyClaimExtended">
                          <s:OEMClaimNumber>00112233445566778899</s:OEMClaimNumber>
                          <gwm:Attachment xmlns:gwm="http://(gwmNamespace)">
                            <gwm:AttachmentId>5678987</gwm:AttachmentId>
                            <gwm:Filename>14.jpg</gwm:Filename>
                          </gwm:Attachment>
                        </s:WarrantyClaim>
                      </s:RepairOrder>
                    </s:Disposition>
                  </s:Header>
                </s:ServiceProcessingAdvisory>
              </s:DataArea>
            </s:ShowServiceProcessingAdvisory>
          </tran:content>
        </tran:payload>
      </tran:ProcessMessageResponse>
    </soapenv:Body>
  </soapenv:Envelope>

  --uuid:36875c60-630c-4e23-9e74-f9a9c7547fc7--

I'm assuming this is an error due to the MIME parts, but how should this be handled?

Might I just add that this is the exact same XML returned in SoapUI and is the expected returned XML. Also, I might add that WSE is required for 2 reasons, because the third party developer of the web service refuses to change their working methods, and we also have a reliance on VS 2005 and therefore can't utilise WCF, espaecially with a deadline hanging over us.

EDIT: The actual response I receive is below, I formatted it above for ease of reading

HTTP/1.1 200 OK
Date: Mon, 16 Jan 2012 09:44:22 GMT
Server: ACE XML Gateway
Cache-Control: no-cache="Set-Cookie"
Set-Cookie: JSESSIONID=h3LnPTxYdZJ3wp4zFl2GV3BYQ7fZD1p8WbvPgl1Qq95g1F9GQhMC!1396094632; path=/
X-Powered-By: Servlet/2.5 JSP/2.1
Content-Type: multipart/related; type="application/xop+xml";  boundary="uuid:a9a94e4e-5134-4995-8884-dfd4d65b7784"; start="<rootpart*[email protected]>"; start-info="text/xml"
Content-Length: 2296
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive


--uuid:a9a94e4e-5134-4995-8884-dfd4d65b7784
Content-Type: application/xop+xml;charset=utf-8;type="text/xml";
Content-ID: <rootpart*[email protected]>
content-transfer-encoding: binary

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><payloadManifest xmlns="http://www.starstandards.org/webservices/2005/10/transport"><manifest contentID="content0" element="ProcessAttachment" namespaceURI="http://www.starstandards.org/STAR" version="2.01"/></payloadManifest></soapenv:Header><soapenv:Body><tran:ProcessMessageResponse xmlns="http://www.starstandards.org/STAR" xmlns:ns2="http://www.gm.com/2006/GWM" xmlns:ns3="http://www.starstandards.org/webservices/2005/10/transport" xmlns:tran="http://www.starstandards.org/webservices/2005/10/transport"><tran:payload><tran:content id="content0"><s:ShowServiceProcessingAdvisory xmlns:s="http://www.starstandards.org/STAR"><s:ApplicationArea><s:Sender><s:Component>Global Warranty Management</s:Component><s:Task>ShowAttachments</s:Task><s:CreatorNameCode>General Motors</s:CreatorNameCode><s:SenderNameCode>GM</s:SenderNameCode></s:Sender><s:CreationDateTime>2012-01-16T09:44:24Z</s:CreationDateTime><s:Destination><s:DestinationNameCode>XX</s:DestinationNameCode><s:DealerNumber>253909</s:DealerNumber><s:DealerCountry>US</s:DealerCountry></s:Destination></s:ApplicationArea><s:DataArea><s:Show/><s:ServiceProcessingAdvisory><s:Header><s:SecondaryDealerNumber>253909</s:SecondaryDealerNumber><s:Disposition><s:RepairOrder><s:WarrantyClaim xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:WarrantyClaimExtended"><s:OEMClaimNumber>001116695583</s:OEMClaimNumber><gwm:Attachment xmlns:gwm="http://www.gm.com/2006/GWM"><gwm:AttachmentId>5677606</gwm:AttachmentId><gwm:Filename>1127.jpg</gwm:Filename></gwm:Attachment></s:WarrantyClaim></s:RepairOrder></s:Disposition></s:Header></s:ServiceProcessingAdvisory></s:DataArea></s:ShowServiceProcessingAdvisory></tran:content></tran:payload></tran:ProcessMessageResponse></soapenv:Body></soapenv:Envelope>

--uuid:a9a94e4e-5134-4995-8884-dfd4d65b7784--
Epaulet answered 10/1, 2012 at 14:43 Comment(3)
Could you show full response, especially beginning from HTTP/1.0?Silurian
Did your problem get resolved? I am facing the same issue. Can you please share your learnings/finding? Thx in advance.Toting
Please see 2 follow up questions that I posted about this. #8882194 and #8986014 Hope they can help you.Epaulet
T
2

I don't know if it was an oversight when creating the post, but if the response does indeed have two spaces before the <?xml?> declaration, then that is the syntax error. If an xml declaration occurs, it MUST be the first thing in the document, nothing else (even whitespace) first.

http://www.w3.org/TR/REC-xml/#sec-prolog-dtd

Removing those spaces, the document looks well-formed, so I don't know what else it would be.

Tillandsia answered 14/1, 2012 at 4:24 Comment(1)
I formatted the xml just for ease of reading, the full HTTP response, as received, is shown above now.Epaulet
C
2

Because of the first line, your XML will only be a valid if it's stored and opened in UTF-8 format. If you were to save this into notepad, say, and save it as "sample.xml", when you open it in Internet Explorer it will display it as a well formed XML.

However, if you were to load this response, in, say, a Unicode string and feed it to an XML parser, it will complain that your string is Unicode whilst the content is UTF-8.

One simple solution is to strip the line before feeding it to your XML parser. This will give you initial success, but, ultimately, for correctness, if you expect to have internationalization, you ought to be providing your content to your XML parser as a byte stream.

Cairns answered 19/1, 2012 at 5:1 Comment(2)
Unfortunately we have been advised that the way our request is formatted is not accepted by the third party, even though it works! So we have to find another solution for the request. And we don't have any control over what the server sends us, it is a third party web service.Epaulet
That's a bummer, you get that extra content "--uuid" that breaks the XML. Perhaps going back to basics with WebRequest and HttpWebRequest and using fiddler as a Web Debugging tool would be the way to go then.Cairns
W
2

you can make use of string operators to just extract the 2 lines containing xml code. for instance if you are using javascript you would

all of this needs to be done after you receive response and before you parse it as xml

if you don't use javascript you can do the same by using regexp

in the even worse case, if your environment doesn't support any of the things i said, you can go for an old way: read line by line , when you first find a "<" as first character, save that line, read one more and stop.

Welldisposed answered 20/1, 2012 at 2:11 Comment(1)
regexp could be something like /(<soapenv:Envelope*soapenv:Envelope>)/ this will catch the line with code and you may need to prepend manually the <?xml lineWelldisposed

© 2022 - 2024 — McMap. All rights reserved.