2

I have two separate interfaces and two separate endpoints (.svc files) defined in a single WCF project. These interfaces share common objects in the project. Is there a way to create a single proxy that combines both interfaces and all the objects, since they are shared?

Thanks!

laconicdev
  • 6,360
  • 11
  • 63
  • 89
  • marc, while searching here, I ended up finding another thread (I lost the url) which suggested using the following svc syntax: svcutil.exe /ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version35 /n:*,MyNamespace http://localhost/MyService/Services/Service1.svc?wsdl http://localhost/MyService/Services/Service2.svc?wsdl http://localhost/MyService/Services/Service3.svc?wsdl By doing this, I was able to create a single proxy which had three interfaces and three client classes, but all objects that were common in the implementation appeared only once. – laconicdev Apr 06 '11 at 16:59

2 Answers2

2

You can implement multiple interfaces in one service:

public class MyService : IContract1, IContract2
{

}

Then you can have a proxy for that service that uses both contracts.

jonnyb
  • 352
  • 1
  • 2
  • 17
1

While searching here, I ended up finding another thread (I lost the url) which suggested using the following svc syntax:

svcutil.exe /ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version35 /n:*,MyNamespace http://localhost/MyService/Services/Service1.svc?wsdl http://localhost/MyService/Services/Service2.svc?wsdl http://localhost/MyService/Services/Service3.svc?wsdl

By doing this, I was able to create a single proxy which had three interfaces and three client classes, but all objects that were common in the implementation appeared only once.

laconicdev
  • 6,360
  • 11
  • 63
  • 89
  • Very interesting indeed ! I had no idea (but frankly also never tried) you could do this! Thanks for sharing! (wish you'd find that URL again - wouldn't it be in your browser's history somewhere??) – marc_s Apr 06 '11 at 17:03
  • Unfortunately it was on a different computer. Basically in the answer, the posted gave a link to http://msdn.microsoft.com/en-us/library/aa347733.aspx If you look in the syntax, the parameter is marked with a * indicating 0 or more instances. – laconicdev Apr 06 '11 at 17:44