从web服务响应中删除响应包装

本文关键字:响应 删除 包装 服务 web | 更新日期: 2023-09-27 18:28:33

是否可以从响应中删除看似自动的通知请求响应节点?

<?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")重命名它,但我希望它消失。按照提供的规范工作,别无选择。

非常感谢。

从web服务响应中删除响应包装

找到了答案。。。

SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare)