Rick Kierner posted on September 29, 2008 17:26

I recently answered a question to a colleague that deserves its own blog posting.  The question simply stated is:

I have two webservices that share types:

webSvc1 at http://myServer/WS/webSvc1.asmx
webSvc2 at http://myServer/WS/webSvc2.asmx

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

wsdl /sharetypes http://myServer/WS/webSvc1.asmx http://myServer/WS/webSvc2.asmx /appsettingurlkey: MyOrgNamespace.MyAppName URL /n:MyOrgNS.Proxy /o:"C:\MyWebApp\App_Code\MyProxy.cs" /l:CS

The problem is that the appsettingurlkey is the same for each 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
service identified

As it turns out, I asked this question on a forum over a year ago and never got a response. I eventually figured it out but got lazy and didn't respond to my own post with the answer.  Here's the answer:

The command line wsdl command doesn't allow for this explicitly.  However, you can use a properties file to make this work. 

Here is the XML Parameter file

 

0:  <wsdlParameters xmlns="http://microsoft.com/webReference/">
1:   <nologo>true</nologo>
2:   <parsableerrors>true</parsableerrors>
3:   <sharetypes>true</sharetypes>
4:   <language>CS</language>
5:   <namespace>MyOrgNS.Proxy</namespace>
6:   <documents>
7:   <document>http://myServer/WS/webSvc1.asmx?WSDL</document>
8:   <document>http://myServer/WS/webSvc2.asmx?WSDL</document>
9:   </documents>
10:   <appSettingUrlKey>MyOrgNamespace.MyAppName</appSettingUrlKey>
11:   <appSettingBaseUrl>http://myServer/WS/</appSettingBaseUrl>
12:   <out>C:\MyPath\Proxy.cs</out>
13:  </wsdlParameters>
</PRE< P>

 

Here is the WSDL Command:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\WSDL" /Parameters:{ENTER_PATH_TO_ABOVE_XML_FILE}"

The important part to note is that each web service starts off with http://myServer/WS/... in the properties XML file.  Then the appSettingBaseURL is "http://myServer/WS/".  Finally, note that the app Setting URL Key is specified as MyOrgNamespace.MyAppName.  In your client's app or web.config file, you'll need to add <add key="MyOrgNS.Proxy" value="http://devServer/SomeURL/"/>  The .cs file that is generated from running the WSDL tool will replace "http://myServer/WS/" with "http://devServer/SomeURL/" before making the http request to the actual service.

Technorati Tags: ,,

Posted in:   Tags:

Comments


 An Phu
November 24. 2008 21:01
An Phu
Hi Rick,

This does not work if the services are in different projects.

E.g.
webSvc1 at http://myServer/WS1/webSvc1.asmx
webSvc2 at http://myServer/WS2/webSvc2.asmx

As you mentioned, the "important part to note is that each web service starts off with http://myServer/WS".

Any clue as to how to make this work if the service are in separate projects?

Thanks,
An

no site

Comments are closed
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Rick.Brain.Flush()