从Web Service Response标头获取MIME类型

时间:2012-03-02 12:46:03

标签: c# web-services header content-type

我调用外部合作伙伴公司提供的Web服务。 Web服务将文件(.pdf,.dox,.png,...)作为字节数组返回。

如果我需要从代码中获取Header信息(详细信息,我对内容类型数据感兴趣),我该如何获取此信息?

就我们而言,我们使用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

1 个答案:

答案 0 :(得分:0)

RESPONSE标题如下所示:

<?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:d3a@example.jaxws.sun.com"/>
  </return></ns2:deliverResponse></S:Body></S:Envelope> 

 Content-Id: <d3a@example.jaxws.sun.com> 
 Content-Transfer-Encoding: binary
 Content-Type: application/pdf    <-- THIS IS THE INFO I NEED TO GET
  

检查Web方法调用中是否有回答您问题的SOAP标头

在Web方法上,我没有任何引用标题的属性/属性。是否有一般方法来获取响应标头,或者是应该提供功能的Web服务来获取它?

(由于要复制的代码,我提供了答案,而不是评论)

相关问题