Question

I have numerous Web Services in my project that share types.

For simplicity I will demonstrate with two Web Services.

WebService1 at http://MyServer/WebService.asmx webService2 at http://MyServer/WebService.asmx

When I generate the proxy for these two services I use:

wsdl /sharetypes http://MyServer/WebService1.asmx http://MyServer/WebService2.asmx /appsettingurlkey:WebServiceUrl /namespace:MyNamespace /out:MyProxy.cs

The problem is that the appsettingurlkey is the same for each Web Service in the proxy file. I want to be able to specify multiple appsettingurlkey parameters. How is this accomplished? I figure since the /sharetypes parameter became available, there should be a solution for specifying the appsettingurlkey specifically for each Web Service identified.

If this is not possible with the wsdl.exe, what would you propose I do? I would rather not update the generated code that wsdl.exe outputs and I don't want to go through my whole application passing in the Url to each instance of the Web Services.

Was it helpful?

Solution

The proxy classes generated are partial classes, so my solution would be to add your own constructor in a different (non-generated) code file, which explicitly reads a different setting for each proxy.

OTHER TIPS

To suplement Elijah's own answer, here's the email answer I gave him.

I had to blog it because the XML didn't paste well into this text box: http://www.rickdoes.net/blog/archive/2008/09/29/wsdl-shared-types-and-configuration.aspx

Ahh, instead of creating another partial class with an overloaded constructor passing in the Url, the following additional parameters to the wsdl.exe will solve my problem...

wsdl /sharetypes http://MyServer/WebService1.asmx http://MyServer/WebService2.asmx /appsettingurlkey:WebServiceUrl /namespace:MyNamespace /out:MyProxy.cs /appsettingurlkey:BaseSoapUrl /appsettingbaseurl:http://MyServer/

If the web.config has a BaseSoapUrl appSetting, then it will use that to replace the http://MyServer/ sub string from the MyProxy.cs. If the appSetting is not present, then it will just use the path provided in the wsdl.exe (example: {BaseSoapUrl}/WebService1.asmx when using the appSetting or http://MyServer/WebService1.asmx when not using the appSetting).

A thanks goes out to Rick Kierner for pointing me in the right direction.

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