从Web服务响应中删除响应包装器?

时间:2013-08-22 12:31:38

标签: c# .net xml web-services

是否可以从响应中删除看似自动的 notificationRequestResponse 节点?

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  ...
  <soap:Body>
    <notificationRequestResponse xmlns="...">
      <notificationResponse xmlns="...">
        <success xmlns="">boolean</success>
        <fault xmlns="">
          ...
        </fault>
      </notificationResponse>
    </notificationRequestResponse>
  </soap:Body>
</soap:Envelope>

我需要返回以下内容:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  ...
  <soap:Body>
    <notificationResponse xmlns="...">
      <success xmlns="">boolean</success>
      <fault xmlns="">
        ...          
      </fault>
    </notificationResponse>
  </soap:Body>
</soap:Envelope>

我希望notificationResponse成为响应的根源!

WebMethod目前没有逻辑,但是:

return new notificationResponse()

notificationRequestResponse来自哪里?我可以使用WebMethod SoapDocumentMethod(ResponseElementName =“new name”)重命名它,但我希望它消失了。按照提供的规范工作,别无选择。

赞赏。

1 个答案:

答案 0 :(得分:1)

找到答案......

SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare