Wcf 如何防止以下嵌套soap请求?

Wcf 如何防止以下嵌套soap请求?,wcf,soap,Wcf,Soap,我有一个定义如下的WCF操作: [OperationContract(Name="GetColorsRQ")] GetColorsRS GetColors(GetColorsRQ rq); 其中getcolorsr将保存响应,GetColorsRQ保存请求。当我运行它时,它会创建以下soap请求(我只包括请求的开头) .... 当我使用来自asmx服务的同一请求时,它不会嵌套该请求,它将按照以下方式执行: <soapenv:Envelope xmlns:soapenv="http:/

我有一个定义如下的WCF操作:

[OperationContract(Name="GetColorsRQ")]
GetColorsRS GetColors(GetColorsRQ rq);
其中
getcolorsr
将保存响应,
GetColorsRQ
保存请求。当我运行它时,它会创建以下soap请求(我只包括请求的开头)


....
当我使用来自asmx服务的同一请求时,它不会嵌套该请求,它将按照以下方式执行:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:ns="http://www.abc.com">
<soapenv:Header/>
<soapenv:Body>
      <ns:GetColorsRQ Target="Test" Version="0">
      ....

....

请注意,现在没有ns:rq,属性已放置在ns:GetColorsRQ节点上。

经过研究,我决定必须使用MessageContract而不是DataContract来更好地控制消息

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:ns="http://www.abc.com">
<soapenv:Header/>
<soapenv:Body>
      <ns:GetColorsRQ Target="Test" Version="0">
      ....