我對如何在我的SOAP請求中添加附件感到疏離。我們必須消費一個以java編寫的第三方Web服務,這是我遇到過的最令人費解的事情。我們使用的任何其他Web服務(即所需的附件)都具有用於添加附件的方法或屬性。簡單。但是,這個沒有提供這樣的方法。將附件添加到SOAP請求
我們已經收到了SOAP消息的一個版本,這與我們想要的XML完全相同,但它是我們無法添加的文件的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>
[email protected]�
--MIMEBoundary--
我已經在互聯網上尋找答案,但已經空白。似乎沒有太多關於使用WSE的文檔。我必須強調,WSE是服務器端的一項要求,我無法改變技術來解決這個問題。
有沒有辦法可以添加這些MIME部分?
編輯:我必須補充說我可以通過附件發送通過SoapUI發送的工作XML文檔,但似乎無法在我們的代碼中找到方法。
我已經添加了一個賞金來試圖解決這個問題。如果有人有任何其他想法,請讓我知道。
再次編輯:我知道這已經過去了一個星期,因爲我能夠在這裏查看回復,但是當一些人提供了一個好主意的時候,我仍然畫空白。圍繞XopDocument
及其方法的可怕文檔是一個很大的問題,如果任何人有任何使用SaveToXopPackage
的例子,他們能否請他們提供,因爲這是開始磨合!
WSE已過時,無論如何都不應使用。 –
約翰,如何提出一個解決方案,而不是繞着假裝你知道一切。在這種情況下,對我而言,WSE是必需的。沒有它,我們的請求將被拒絕。我無法告訴第三方供應商他們應該如何編碼,我可以嘗試,但他們一直是世界上最沒有幫助的公司。因此,如果您正在創建自己的軟件,則不應使用WSE,但在此情況下這是一項要求。 – anothershrubery
顯然這是一個商業決定,您的公司是否應該繼續與需要使用過時軟件的第三方開展業務,而不是與其他競爭對手不同。 –