Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Setting web service endpoint just once

$
0
0

I have an ASP.NET web application in Visual Studio 2015.  I have updated it to consume web services from a third-party which has provided a WSDL file as follows:

  • I copied the WSDL file to my project folder, and auto-generated the client code as follows:  From my Windows Start menu, I opened "Developer Command Prompt for VS2015", changed directories to my project folder, and issued the wsdl.exe command (i.e., >wsdl partner.wsdl)
  • A "partner.cs" file was created in my project folder at the same level as the wsdl file.  I moved it to my App_Code folder.
  • I then added the service reference by right- clicking the project in the Solution Explorer, then clicking "Add Service Reference".  This adds the service endpoint to my web.config file, and adds the svcmap (a few files) to App_WebReferences.

The good news is that I am able to successfully consume the web services.  The problem is that the web service endpoint address is hard-coded in the generated files in several places:  "partner.cs" file generated from the WSDL (because WSDL had enpoint hard-coded), the web.config file, and the  App_WebReferences files.  I would like to have it specified in only one spot; e.g.., the web.config file, or even better, in my DB so I can set an Application variable when my application starts.  I haven't been able to use an Application variable from these files, so I'm stuck, and wondering if I did something wrong in my steps outlined above to end up with endpoints in multiple spots.

I am deploying my application to customers, and would like them to have an easy time changing the endpoint (e.g., from test url to prod url).

Any suggestions would be appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images