【问题标题】:How do I remove operation element from soap envelope body in WCF?如何从 WCF 中的肥皂信封主体中删除操作元素?
【发布时间】:2015-09-19 09:36:09
【问题描述】:

我有一个 WCF 服务设置,主要是根据客户的规范设置,但我试图根据客户的示例请求排除信封主体所需的一个额外元素。

这些是我的服务和运营合同:

[ServiceContract(Namespace="http://www.somenamespace.com")]
public interface IProcessPayment
{
    [OperationContract]
    ResponseSubmitPayment execute(RequestSubmitPayment RequestSubmitPayment);
}

这是他们发送来测试我的服务的内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
<soapenv:Header/>
  <soapenv:Body>
    <pay:RequestSubmitPayment>
       <!-- irrelevant stuff -->
    </pay:RequestSubmitPayment>
  </soapenv:Body>
</soapenv:Envelope>

这就是我的服务所期望的(基于 SOAPUI):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pay="http://www.somenamespace.com">
   <soapenv:Header/>
   <soapenv:Body>
      <pay:execute> <!-- I want to remove this! -->
         <pay:RequestSubmitPayment>
            <!-- irrelevant stuff -->
         </pay:RequestSubmitPayment>
      </pay:execute> <!-- I want to remove this! -->
   </soapenv:Body>
</soapenv:Envelope>

如何将我的 WCF 服务配置为不需要或排除该元素?客户告诉我,他们有许多其他客户成功地测试和实施了它。 SOAP 1.1 是我对他们发送的内容的理解。

提前致谢!

【问题讨论】:

  • 不确定在操作合同中是否可行。尝试使用消息协定,如果也不起作用,则使用带有方法标志 ParameterStyle = SoapParameterStyle.Bare 的 xmlserializer 协定
  • 看起来很有趣!我试试看!
  • @YaronNaveh 请发布您的回复(尤其是 MessageContract)作为答案。

标签: web-services wcf soap


【解决方案1】:

不确定它在操作合同中是否可行。尝试使用消息合约,它将为您提供所需的灵活性。如果失败,请使用带有方法标志 ParameterStyle = SoapParameterStyle.Bare 的 xmlserializer 合同。

【讨论】:

  • 澄清一下 - MessageContract 允许我做我需要做的事情。
  • @Zach 我遇到了同样的问题,你能告诉我你是如何使用 MessageContract 的吗?
  • @KevinBui 哦,男孩,这是不久前的事了,但我相信我的最终解决方案最终会有所不同。我想我采用了他们拥有的 wsdl 并基于此生成了服务。它更好/更清洁。
猜你喜欢
  • 2015-08-25
  • 1970-01-01
  • 2021-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-10
  • 2019-10-01
  • 1970-01-01
相关资源
最近更新 更多