WSDL first WCF server where client does not send SOAPAction

后端 未结 1 658
遇见更好的自我
遇见更好的自我 2020-12-09 00:45

I am implementing a WCF web service which interacts with a client whose code I do not control. The WSDL was supplied by the client.

I generated C# files from the WSD

相关标签:
1条回答
  • 2020-12-09 01:29

    The following worked for me (based on this thread):

    1. Download the Microsoft WCF examples.
    2. Add the following files to your project from WF_WCF_Samples\WCF\Extensibility\Interop\RouteByBody\CS\service
      • DispatchByBodyOperationSelector.cs
      • DispatchByBodyBehaviorAttribute.cs
    3. Add the following attributes to your interface (next to your ServiceContract)
      • XmlSerializerFormat
      • DispatchByBodyBehavior
    4. Add the following to your service interface

      [OperationContract(Action = "")]
      public void DoNothing()
      {
      }
      
    5. For my service the WrapperName and Wrappernamespace are null for all messages. I had to go into DispatchByBodyBehaviorAttribute and edit ApplyDispatchBehavior() to add the following lines to check for this:

       if (qname.IsEmpty) {
           qname = new XmlQualifiedName(operationDescription.Messages[0].Body.Parts[0].Name, operationDescription.Messages[0].Body.Parts[0].Namespace);
       }
      
    0 讨论(0)
提交回复
热议问题