Alexey
Alexey

Reputation: 453

WCF service with multiple service contracts with duplicate method names in single wsdl

Continuing this and this questions. I have two service contract with the same methods:

[ServiceContract]
public interface IServices1
{
    [OperationContract]
    string GetData(int value);
}

[ServiceContract]
public interface IServices2
{
    [OperationContract]
    string GetData(int value);
}

And service:

public class Service : IServices1, IServices2
{
    string IServices1.GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

    string IServices2.GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }
}

According to reasons beyond my control:

System.NotSupportedException: A single WSDL document could not be generated for this service. Multiple service contract namespaces were found (IServices1, IServices2). Ensure that all your service contracts have the same namespace.

Summarizing, I need WCF service with multiple service contracts with duplicate method names in single wsdl. Is there a way to achieve it?

Upvotes: 1

Views: 2769

Answers (1)

Ricardo Pontual
Ricardo Pontual

Reputation: 3757

Generate your classes from the wsdl file. Save the content of http://pastebin.com/277DFF7H in a file, like "service.wsdl". Don't forget that <?xml version="1.0" encoding="UTF-8"?> tag must be at first like, first column.

Then run the wsdl.exe util from Developer Command Prompt , like this:

wsdl service.wsdl /out:service.cs

Now you have the contracts as wsdl requires, and you can do any changes you need.

Hope it helps.

Upvotes: 1

Related Questions