WCF方法返回空消息元素

时间:2013-07-09 12:52:14

标签: asp.net wcf

我正在调用典型的SOAP WCF方法void HelloWorld();

不幸的是,它的响应如下:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<HelloWorld xmlns="http://tempuri.org/"/>
</s:Body>
</s:Envelope>

我有什么方法可以从响应中删除<HelloWorld xmlns="http://tempuri.org/"/>行(基本上是空的<s:Body>)?

1 个答案:

答案 0 :(得分:1)

如果您将此声明为“裸”服务,也许它会起作用:

[SoapDocumentService(Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Bare)]

否则实施custom message inspector(如果它不起作用,则为custom message encoder)以更改消息。