SOAP リクエストに添付ファイルを追加する方法について、私は迷っています。Java で構築されたサード パーティの Web サービスを使用する必要がありますが、これは私が今まで遭遇した中で最も複雑なものです。添付ファイルを必要とする他の Web サービスには、添付ファイルを追加するためのメソッドまたはプロパティがあります。単純。ただし、これはそのような方法を提供しません。
必要な XML とまったく同じバージョンの SOAP メッセージを一緒に取得しましたが、追加できないのはファイルの MIME 部分です。
例:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<soap:Header>
<payloadManifest xmlns="http://<examplePayload>">
<manifest contentID="Content0" namespaceURI="http://<exampleManifest>" element="ProcessRepairOrder" version="2.01" />
</payloadManifest>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2011-12-19T15:25:13Z</wsu:Created>
<wsu:Expires>2011-12-19T15:30:00Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken><wsse:Username>username</wsse:Username><wsse:Password>password</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><ProcessMessage xmlns="<examplePayload"><payload><content id="Content0">
<s:ProcessRepairOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.xsd" xmlns:s="http://<exampleManifest>" xmlns:gwm="http://example">
<s:ApplicationArea>
<s:Sender>
<s:Component>Test</s:Component>
<s:Task>ProcessAttachment</s:Task>
<s:CreatorNameCode>Test</s:CreatorNameCode>
<s:SenderNameCode>XX</s:SenderNameCode>
<s:DealerNumber>111111</s:DealerNumber>
<s:DealerCountry>GB</s:DealerCountry>
</s:Sender>
<s:CreationDateTime>2010-03-26T13:37:05Z</s:CreationDateTime>
<s:Destination>
<s:DestinationNameCode>GM</s:DestinationNameCode>
<s:DestinationURI/>
<s:DestinationSoftwareCode>GWM</s:DestinationSoftwareCode>
</s:Destination>
</s:ApplicationArea>
<s:DataArea xsi:type="gwm:DataAreaExtended">
<s:Process/>
<s:RepairOrder>
<s:Header xsi:type="gwm:RepairOrderHeaderExtended">
<s:DocumentId/>
</s:Header>
<s:Job xsi:type="gwm:JobExtended">
<s:JobNumber/>
<s:OperationId>Test</s:OperationId>
<s:OperationName/>
<s:CodesAndComments/>
<s:Diagnostics/>
<s:WarrantyClaim xsi:type="gwm:WarrantyClaimExtended">
<s:OEMClaimNumber>00112233445566778899</s:OEMClaimNumber>
<gwm:Attachment>
<gwm:File><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test.gif"/></gwm:File>
<gwm:Filename>test.gif</gwm:Filename>
</gwm:Attachment>
</s:WarrantyClaim>
<s:LaborActualHours>0.0</s:LaborActualHours>
<s:Technician/>
</s:Job>
</s:RepairOrder>
</s:DataArea>
</s:ProcessRepairOrder>
</content></payload></ProcessMessage></soap:Body></soap:Envelope>
これは、生成して送信できる XML 部分ですが、次のような MIME 部分が必要なため、正しくありません。
XML の前:
--MIMEBoundary
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <rootpart>
XMLの後
--MIMEBoundary
Content-Type: image/gif; name=test.gif
Content-Transfer-Encoding: binary
Content-ID: <test.gif>
GIF89a@�
--MIMEBoundary--
インターネットで答えを探しましたが、空白になりました。この目的での WSE の使用に関するドキュメントはあまりないようです。WSE はサーバー側の要件であることを強調しなければなりません。この問題に対処するためにテクノロジを変更する方法はありません。
これらの MIME セクションを追加する方法はありますか?
編集: SoapUI を介して添付ファイル付きで送信された動作中の XML ドキュメントを取得できることを追加する必要がありますが、コード内で方法を見つけることができないようです。
この問題を解決するための報奨金を追加しました。他のアイデアがある場合は、お知らせください。
もう一度編集: ここで回答を確認できてから 1 週間が経ちましたが、どこを見ればよいかについて良い考えを示している人もいますが、まだ空白を描いています。ひどいドキュメンテーションXopDocument
とそのメソッドは大きな問題です。誰かが使用例を持っている場合は、SaveToXopPackage
提供してください。