小编use*_*352的帖子

WCF消息:如何删除SOAP Header元素?

我尝试从WCF消息中删除整个SOAP标头,只想离开信封体.任何人都可以告诉我怎么做到这一点?

像这样创建一个WCF消息:

**string response = "Hello World!";
Message msg = Message.CreateMessage(MessageVersion.Soap11, "*", new TextBodyWriter(response));
msg.Headers.Clear();**
Run Code Online (Sandbox Code Playgroud)

发送SOAP消息将是:

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

但我不想要SOAP头元素,我只需要包络体.如何从WCF消息中删除头元素?

.net c# wcf soap wcf-binding

4
推荐指数
2
解决办法
8757
查看次数

标签 统计

.net ×1

c# ×1

soap ×1

wcf ×1

wcf-binding ×1