我正在使用Web服務來處理數據。就我看來,我正在發送請求。我添加了來自wsdl的Web引用並添加了一個安全令牌。但是,當我試圖得到響應,它拋出以下錯誤:客戶端發現響應內容類型爲'multipart/related
Invalid Operation Exception: 「Client found response content type of 'multipart/related".
按我的理解,我得到以下錯誤,因爲該服務使用MTOM發送PDF文件。有什麼方法可以修復網頁引用,因爲它可以正確解碼MTOM,或者我應該爲它創建一個解碼器。併發送請求而不使用Web引用。
我嘗試使用行響應,並把它傳遞給MTOM讀者
XmlDictionaryReader mtomReader = XmlDictionaryReader.CreateMtomReader(response.GetResponseStream() , Encoding.UTF8, XmlDictionaryReaderQuotas.Max);
但是,讓另一個錯誤
System.Xml.XmlException: Content-Type header for MTOM message not found.
響應例如:
--MIMEBoundaryurn_uuid_F468164F66D5B7FD071377072332741
Content-Type: application/xop+xml; charset=iso-8859-1; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:[email protected]>
皁XML
--MIMEBoundaryurn_uuid_F468164F66D5B7FD071377072332741
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:[email protected]>
PDF二進制
--MIMEBoundaryurn_uuid_F468164F66D5B7FD071377072332741--