小编kap*_*pie的帖子

如何将HTTP标头添加到SOAP客户端

如果有可能将HTTP标头添加到soap客户端Web服务调用,有人可以回答我.浏览互联网后,我发现的唯一的薄是如何添加SOAP标头.

代码如下所示:

var client =new MyServiceSoapClient();
//client.AddHttpHeader("myCustomHeader","myValue");//There's no such method, it's just for clearness
var res = await client.MyMethod();
Run Code Online (Sandbox Code Playgroud)

更新:

The request should look like this
POST https://service.com/Service.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.host.com/schemas/Authentication.xsd/Action"
Content-Length: 351
MyHeader: "myValue"
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header/>
  <s:Body>
    <myBody>BodyGoesHere</myBody>
  </s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)

信封中的标题属性应为空

c# soap-client windows-8

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

soap-client ×1

windows-8 ×1