Question

I am consuming a predefined wsdl with svcutil:

svcutil some_service.wsdl

We are using this to set up a mock server for testing a client.

The generated code looks like the following:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://LIB-Operations/interfaces/ServiceResponse", ConfigurationName = "ServiceResponse")]
public interface ServiceInterface
{
    [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action="")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    void Operation1(OperationRequest1 request);

    [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action="")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    void Operation2(OperationRequest2 request); 
}

This causes the following exception:

System.InvalidOperationException: The operations Operation1 and Operation2 have the same action ().  Every operation must have a unique action value.

If I remove the

Action=""

I receive the following exception:

System.ServiceModel.ProtocolException: The one-way operation returned a fault message.  The reason for the fault was '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).'.

Note that if there is only one operation in the contract there is no problem. This is only a problem when used in a server, this is no issue using the generated code in a client.

What is the correct way to handle this situation? I can not modify the client (it must be backed by the unmodified code generated by svcutil), but can modify the code generated by svcutil used in our mock server.

Was it helpful?

Solution

Action is meant to filter out incoming request at server. Here both of your operations or methods i.e. operation1 and operation2 is taking (OperationRequest request) same object as input. So your server will check Action attribute of request message to figure out which operation should it call for incoming request.

Here is your answer.

WSDL first WCF server where client does not send SOAPAction

Edit:

If you can not edit your client then, in mock server you can try removing Action property in soapDocumentMethod attribute.It must be set as soapDocumentMethod[Action="",OneWay=value] something like this, remove Action part and try to regenerate your client, let's see it works or not.

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