Question

I have one WCF service and two console app clients.

Service: The service code is created from a wsdl contact using WCSF Blue tool.

Client 1: This client is using wsdl that is obtained by browsing the svc file. This browsed wsdl file is slightly different from the contract wsdl file.

Client 2: This client is created using the original wsdl contract.

Cleint1 is working fine. Client 2 is not working. What all could be potential issues?

App.Config file of both the clients look similar – only the name changes. I think, the problem will be in the client C# code generated – most probably in the ActionReplyAction. What need to be corrected here?

One noticeable difference is in Action and ReplyAction

Client 1:

Action="urn:lijo:demos:multiplyservice:calculation:v1/ICalculationService/GetMultiplied", ReplyAction="urn:lijo:demos:multiplyservice:calculation:v1/ICalculationService/GetMultipliedRe" + "sponse"

Client 2:

Action="urn:lijo:demos:multiplyservice:calculation:v1:getMultipliedIn", ReplyAction="*"

Trace Message

The message with Action 'urn:lijo:demos:multiplyservice:calculation:v1:getMultipliedIn' 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).

EDIT

This can be corrected by changing the Action and ReplyAction as below (Copied it from Service).

  [System.ServiceModel.OperationContractAttribute(Action = "urn:lijo:demos:multiplyservice:calculation:v1/ICalculationService/getMultiplied", ReplyAction = "urn:lijo:demos:multiplyservice:calculation:v1/ICalculationService/getMultipliedRe" +
        "sponse")]

Note: It is important to ensure that the casing in the service is correct (i.e, getMultiplied not GetMultiplied)

Copying from the service is not a good option, though it works. What would be the correct Action and ReplyAction?

Also, Can you please point out how to modify the wsdl so that the ReplyAction will be correct in the generated client proxy? That is the essential part to mark it as answered.

WCF: Actions, Asterisk and Metadata

WsdlExporter, which is used for metadata publishing, ignores operations with asterisk actions (both Action and ReplyAction).

From MSDN -ReplyAction Property

Specifying an asterisk in the service instructs WCF not to add a reply action to the message, which is useful if you are programming against messages directly.

REFERENCES:

  1. WCF metadata missing operations

RestaurantData.xsd

 <?xml version="1.0" encoding="utf-8" ?>
 <xs:schema id="RestaurantData" targetNamespace="urn:lijo:demos:multiplyservice:data:v1"
    elementFormDefault="qualified" xmlns="urn:lijo:demos:multiplyservice:data:v1"
    xmlns:mstns="urn:lijo:demos:multiplyservice:data:v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:complexType name="multipliedResult">
  <xs:sequence>
  <xs:element name="resultNumber" type="xs:int" />
   </xs:sequence>
   </xs:complexType>

  </xs:schema>

Original Contract wsdl

 <definitions xmlns:import0="urn:lijo:demos:multiplyservice:messages:v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:import1="urn:lijo:demos:multiplyservice:data:v1" xmlns:tns="urn:lijo:demos:multiplyservice:calculation:v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CalculationService" targetNamespace="urn:lijo:demos:multiplyservice:calculation:v1" xmlns="http://schemas.xmlsoap.org/wsdl/">

 <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
 <types>
 <xsd:schema>
  <xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantMessages.xsd" namespace="urn:lijo:demos:multiplyservice:messages:v1" />
  <xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantData.xsd" namespace="urn:lijo:demos:multiplyservice:data:v1" />
</xsd:schema>
</types>
<message name="getMultipliedIn">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultiplied" />
</message>
<message name="getMultipliedOut">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultipliedResponse" />
</message>
<portType name="CalculationServiceInterface">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<operation name="getMultiplied">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
  <input message="tns:getMultipliedIn" />
  <output message="tns:getMultipliedOut" />
</operation>
</portType>
<binding name="BasicHttpBinding_CalculationServiceInterface" type="tns:CalculationServiceInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getMultiplied">
  <soap:operation soapAction="urn:lijo:demos:multiplyservice:calculation:v1:getMultipliedIn" style="document" />
  <input>
    <soap:body use="literal" />
  </input>
  <output>
    <soap:body use="literal" />
  </output>
 </operation>
 </binding>
 <service name="CalculationServicePort">
 <port name="CalculationServicePort" binding="tns:BasicHttpBinding_CalculationServiceInterface">
  <soap:address location="http://localhost/CalculationService" />
 </port>
 </service>
 </definitions>
Was it helpful?

Solution

I figured it out. For the benefit of others I will explain it here.

Before that please refer answer to the 400 Bad Request Exception: Simple SOAP WCF service with small data for some debugging ideas.

This due to Format SOAP Action option in WCSF Blue tool.

I have used "Format Soap Actions" while generating the code using WCSF Blue. But while client, I did not use the tool. That mismatch is the key issue.

Format Soap Actions force the SOAP actions (Action and ReplyAction) applied to each operation contract follow the standard WCF format:

  <namespace>/<service>/<operation>[Response] 

If I have no control over the client, I should not use Format SOAP Action option in WCSF Blue Tool.

Please refer Service works from wcfTestClient but fails in Console Application for a working example.

[Still I have a question - what if I have no control over the client still need to use ReplyAction? What will be the URI in xml format in such scenario that is to be used in the client and service ? ]

General Debugging Ideas:

  1. Ensure that the service is good by using wcfTestClient (type wcfTestClient in VS command prompt to launch)

  2. Use Tracing as mentioned in How to turn on WCF tracing?

  3. Verify that the configuration values are in web.config/app.config and not in output.config (in case of auto generation using tools)

  4. Verify that you are referring proper wsdl (is it local file or url from running service?)

  5. Verify that the wsdl can be viewed by browsing the svc file. Metadata is enabled

  6. Check whether it is relative path or absolute path in the "address" in the service

OTHER TIPS

You are right that there is an issue in ReplyAction. When ReplyAction is set to "*" makes WCF to ignore that operation. Correct the ReplyAction to your operation contract will work.

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/41f5fe72-3ab3-4741-867e-a93119fe62aa

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top