5

添付ファイル付きのリクエストを送信し、サーバーからさまざまな情報を含む応答を受信するWebサービスを利用しています。別の質問でリクエストをまとめる際のいくつかの問題を文書化しましたが、SOAPリクエストに添付ファイルを追加しましたが、このビットは解決され、応答に別の問題が発生しました。

応答はOKですが、次のようなエラーがスローされます。

応答は整形式のXMLではありません。

InnerExceptionは次のとおりです。

WSE1608:指定されたコンテンツIDのストリームにXOPパーツが見つかりませんでした:<rootpart * 36875c60-630c-4e23-9e74-f9a9c7547fc7@example.jaxws.sun.com>

返されるxmlは次のようになります。

--uuid:36875c60-630c-4e23-9e74-f9a9c7547fc7
Content-Type: application/xop+xml;charset=utf-8;type="text/xml";
Content-ID: <rootpart*36875c60-630c-4e23-9e74-f9a9c7547fc7@example.jaxws.sun.com>
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--

これはMIME部分によるエラーだと思いますが、どのように処理すればよいですか?

これはSoapUIで返されるのとまったく同じXMLであり、予想される返されるXMLであると付け加えてもよいでしょう。また、WSEが必要な理由は2つあります。これは、Webサービスのサードパーティ開発者が作業方法の変更を拒否していることと、VS 2005に依存しているため、特に期限付きでWCFを利用できないためです。私たちの上にぶら下がっています。

編集:私が受け取る実際の応答は以下のとおりです。読みやすくするために上でフォーマットしました。

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*a9a94e4e-5134-4995-8884-dfd4d65b7784@example.jaxws.sun.com>"; 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*a9a94e4e-5134-4995-8884-dfd4d65b7784@example.jaxws.sun.com>
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--
4

3 に答える 3

2

投稿を作成するときに見落としだったかどうかはわかりませんが、応答の前に<?xml?>宣言の前に2つのスペースがある場合は、構文エラーです。xml宣言が発生した場合、それはドキュメントの最初のものでなければならず、他には何も(空白でさえ)最初になければなりません。

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

これらのスペースを削除すると、ドキュメントは整形式に見えるので、他に何になるかわかりません。

于 2012-01-14T04:24:25.070 に答える
2

最初の行のため、XML は UTF-8 形式で保存されて開かれた場合にのみ有効になります。これをたとえばメモ帳に保存し、「sample.xml」として保存すると、Internet Explorer で開くと整形式の XML として表示されます。

ただし、この応答をたとえば Unicode 文字列で読み込んで XML パーサーに渡すと、コンテンツが UTF-8 であるのに、文字列が Unicode であるとエラーが表示されます。

簡単な解決策の 1 つは、XML パーサーに渡す前に行を削除することです。これで最初は成功しますが、国際化を期待している場合は、正確を期すために、コンテンツを XML パーサーにバイト ストリームとして提供する必要があります。

于 2012-01-19T05:01:53.260 に答える
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.

于 2012-01-20T02:11:54.987 に答える