Short question:
1. How to use Svcutil or other utilities to generate proxy for particular contract in multiple contract service
Long Question:
I have created a application with multiple service contracts (with one endpoint for each contract). Now i like to generate the proxy for these service contracts. In the client, i want to generate proxy for specific contract as both the contracts wont be used by same client. So how to use Svcutil or other utilities to generate proxy for particular contract in multiple contract service.
Thanks, Saravana

Generating proxy for multiple Contracts service
Ed Staffin
Hi Daniel Roth,
Thanks for your input. Svcutil is generating proxy as you mentioned only.
-Saravana
VincentCroft
Hello,
Svcutil should generate a proxy for each wsdl port type in the metadata, and there should be a wsdl port type for each service contract. You can then just throw away the proxy code that you don't care about.
Let us know if this isn't adequate or you are seeing a different behavior. Thanks!
Daniel Roth
folsomfisher
You can create an individual servicehost to host each contract. You can create the proxy by using the endpoint that corresponds to the contract being hosted by it.
So for example if you had something like this:
static void Main(string[] args){
WSDualHttpBinding binding1 = new WSDualHttpBinding(); Uri baseAddress1 = new Uri("http://localhost:12000/Alpha/"); ServiceHost host = new ServiceHost(typeof(Alpha), baseAddress1);host.AddServiceEndpoint(
typeof(IAlpha), binding1, baseAddress1);host.Open();
WSDualHttpBinding binding2 = new WSDualHttpBinding(); Uri baseAddress2 = new Uri("http://localhost:12000/Beta/"); ServiceHost host2 = new ServiceHost(typeof(Beta), baseAddress2);host2.AddServiceEndpoint(
typeof(IBeta), binding2, baseAddress2);host2.Open();
Console.WriteLine("Press enter to close"); Console.ReadLine();}
and then ran svcutil for each endpoint you will get separate proxies for IAlpha and IBeta:
SvcUtil.exe http://localhost:12000/Alpha/ /out:alphaproxy.cs
SvcUtil.exe http://localhost:12000/Beta/ /out:betaproxy.cs
The thing to keep in mind here is that the metadata is per servicehost, not endpoint. So if you want to host the endpoints in the same servicehost, you can either create the proxy and delete what you don't want or generated the metadata using the /t switch and delete what you don't want.
Thanks,
Scott
jlfappx
Thanks for your reply. I understand from your reply that if we have two servicehost, we can create proxy separately.
Since i am hosting in IIS, i need to have two web application (or two .svc files) to host these contracts separately.Then only i will have separate metadata from each contract, so that i can generate the proxy separately.
I just like to know is there is any possibility to generate proxies separately for one serice with two contracts which has one svc file and with two end points hosted in IIS (one web app with same base address but with differenent endpoint address)
Please let me know if you need any other details,
Thanks Again for your valuable input,
Saravana.
Microsoft MVP
Lost in VB space
Hi I have exactly the same question as Saravana in terms of generating a specific proxy for a specific contract for a service hosted in IIS. Using the sample code, this uri would be http://localhost/services/service.svc/contract1.
It is my understanding that this will generate a proxy for this contract only, but in my case it seems to have a problem with the /contract1.
If I only include the base address, it returns proxies for all contracts implemented in the service. It is my understanding that each contract can be proxied seperately.
Could you please give me some guidence in how to use WCF to solve the problem specified by Savarana and eloborated by me.
Thank you very much for your assistance,
Johan.