【问题标题】:Best way to build a WCF service using given soap message使用给定的肥皂消息构建 WCF 服务的最佳方法
【发布时间】:2018-11-24 23:14:31
【问题描述】:

我需要为下面给定的 SOAP 消息构建一个服务,我的客户端使用这个 SOAP 消息来调用我的新 WCF 服务。

我开始构建 wcf basicHTTPBinding

我需要知道如何以这样一种方式构建服务以保证接收到客户端的调用。

<soapenv:Envelope
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <ctx:clientContext
      xmlns:ctx="http://ClientContext">
      <ctx:clientUserId>775</ctx:clientUserId>
    </ctx:clientContext>
    <To soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://myserverurl.com/Services/UpdateRequest.svc/soapService</To>
    <Action soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">updateRequestStatus</Action>
  </soapenv:Header>
  <soapenv:Body>
    <p20:updateRequestStatus xmlns:p20="http://com.myservice.update.ws">
      <requestId xmlns="">6699</requestId>
      <status xmlns="">Approved</status>
    </p20:updateRequestStatus>
  </soapenv:Body>
</soapenv:Envelope>

我尝试实现此类服务并将其发布给我的客户以便调用它。客户端调用我的服务时出错:

错误描述如下:

由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action 'updateRequestStatus' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。

我该如何解决这个问题?

【问题讨论】:

    标签: c# wcf soap


    【解决方案1】:

    我通过为给定的 WSDL 生成 C# 类来解决这种情况。它将使用以下命令为该 WSDL 构建一个接口:wsdl "wsdl file path" "xsd file path"。 然后基于生成的类,我创建一个 WCF 服务并为我的服务实现所有必需的方法。

    基于此,任何具有上述soap消息的客户端都可以使用我的服务而不会发生任何冲突。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      • 2020-06-11
      • 2014-10-23
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      相关资源
      最近更新 更多