【问题标题】:Remove the response wrapper from web service response?从 Web 服务响应中删除响应包装器?
【发布时间】:2013-08-22 12:31:38
【问题描述】:

是否可以从响应中删除看似自动的 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") 重命名它,但我希望它消失。按照提供的规范工作,别无选择。

赞赏。

【问题讨论】:

    标签: c# .net xml web-services


    【解决方案1】:

    找到答案了……

    SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-11
      • 2022-01-14
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多