代码之家  ›  专栏  ›  技术社区  ›  Redwood

客户端不发送SOAPAction的WSDL第一个WCF服务器

  •  6
  • Redwood  · 技术社区  · 16 年前

    我正在实现一个wcfweb服务,它与我不控制其代码的客户机交互。WSDL是由客户端提供的。

    here 我没有问题。

    在这一点上,我得到了以下错误:

    The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
    

    然后,我尝试使用客户机提供的WSDL使用SOAPUI。此操作失败,出现上述相同的空操作错误。

    然后我连接了Wireshark(启用SSL解密)并验证了从客户端发送的消息确实缺少SOAPAction,因此看起来这肯定是问题所在。

    1 回复  |  直到 16 年前
        1
  •  18
  •   Redwood    16 年前

    以下对我有用(基于 this 线程):

    1. 下载Microsoft WCF示例。
      • DispatchByBodyOperationSelector.cs调度
      • DispatchByBodyBehaviorAttribute.cs发送
    2. 将以下属性添加到界面(位于 ServiceContract
      • XmlSerializerFormat
      • DispatchByBodyBehavior
    3. 将以下内容添加到服务接口

      [OperationContract(Action = "")]
      public void DoNothing()
      {
      }
      
    4. 对于我的服务,WrapperName和Wrappernamespace是 null 对于所有消息。我不得不进入 DispatchByBodyBehaviorAttribute 编辑 ApplyDispatchBehavior() 要添加以下行以检查此项:

       if (qname.IsEmpty) {
           qname = new XmlQualifiedName(operationDescription.Messages[0].Body.Parts[0].Name, operationDescription.Messages[0].Body.Parts[0].Namespace);
       }
      
    推荐文章