2012-03-02 78 views
0

我調用由外部合作伙伴公司提供的Web服務。 Web服務以字節數組的形式返回文件(.pdf,.dox,.png,...)。從Web服務響應標頭獲取MIME類型

如果我需要獲得報頭信息(詳細情況我感興趣的內容類型的數據)的代碼,我怎麼能得到這個信息?

就我們而言,我們使用VS 2010和C#作爲語言。

下面的代碼:

var client = new PublicService(); 
wsRequest request = new wsRequest(); 

var docInfo = new documentInfo(); 
docInfo.documentId = HSdocumentID; 
docInfo.position = 1; 

request.documentInfos = { docInfo }; 
byte[] doc = client.deliver(deliverRequest); //returns the file as byte array 
+0

您打電話的Web服務的類型是什麼?它是基於SOAP的Web服務,還是REST風格的Web服務? – CSharpenter 2012-03-02 13:13:57

+0

這是一個SOAP Web服務。 Teh合作伙伴公司的開發人員對我說,在Web服務的響應頭中有關於內容類型的數據。我的問題是如何從我的代碼中提取這些信息? – Francesco 2012-03-02 13:24:10

+0

如果您有權訪問Web服務的WSDL,請發佈所需Web方法的SOAP請求/響應示例 – CSharpenter 2012-03-02 13:28:17

回答

0

響應頭看起來像:

<?xml version="1.0" ?> 
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
    <S:Body><ns2:deliverResponse xmlns:ns2="http://www.dalle.com/webservices/record/2012a"> 
    <return> 
     <Include xmlns="http://www.w3.org/2004/08/xop/include" 
         href="cid:[email protected]"/> 
    </return></ns2:deliverResponse></S:Body></S:Envelope> 

Content-Id: <[email protected]> 
Content-Transfer-Encoding: binary 
Content-Type: application/pdf <-- THIS IS THE INFO I NEED TO GET 

退房是否有在Web方法調用回答你的問題SOAP頭

在web方法上,我沒有任何引用標題的屬性/屬性。有沒有一種通用的方式來獲得響應頭或是應該提供功能來獲取它的Web服務?

(我提供了一個答案,而不是評論,由於要複製的代碼)