如果可以将 HTTP 标头添加到肥皂客户端 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();
更新:
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>
信封中的 Header 属性应为空