1

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.

  • I need one service with several endpoints.
  • I need service like this (preferably on WCF).

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

Community
  • 1
  • 1
Alexey
  • 453
  • 7
  • 13
  • You cannot do it, because it's equivalent to overload a method, and it isn't allowed in wsdl. See more here: http://stackoverflow.com/questions/10276124/why-method-overloading-is-not-allowed-in-wcf and here: http://www.w3.org/TR/2002/WD-wsdl12-20020709/ – Ricardo Pontual Oct 28 '15 at 11:31
  • @RicardoPontual How can I get the wsdl like [this](http://pastebin.com/277DFF7H) with WCF? In this wsdl `` have `` and `` have `` in one namespace. – Alexey Oct 28 '15 at 12:13
  • I posted as an answer because it was a little long for a comment – Ricardo Pontual Oct 28 '15 at 12:33
  • You must configure both endpoints in your Web. config, then it can also display the SingleWsdl – naro Oct 17 '17 at 15:02

1 Answers1

1

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.

Ricardo Pontual
  • 3,749
  • 3
  • 28
  • 43
  • Generated file contains description of access to the service described in the `service.wsdl` file. But I need the service with the same interface as that of service with `service.wsdl` description. – Alexey Oct 28 '15 at 12:47
  • 1
    use the serviceinterface paramenter and you will have the interfaces instead classes: wsdl service.wsdl /out:service.cs /serverInterface – Ricardo Pontual Oct 28 '15 at 12:52