codecompleting
codecompleting

Reputation: 9611

How to extract the endpoint url when adding service references?

When added a service reference in vs.net 2008, the url to the wcf service is hardcoded in the generated files.

How can I extract this out to my web.config so I can potentially change the url?

Upvotes: 1

Views: 321

Answers (1)

Michael Edenfield
Michael Edenfield

Reputation: 28338

The service reference should automatically generate configuration data, including the endpoint, into your web.config. The URL will be inside the client configuration:

<endpoint address="http://localhost:8732/Service.svc/" 
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" 
          contract="Service.IService" name="WSHttpBinding_IService" />

When creating a client instance, you also have the option to override the endpoint address in one of the overloaded constructors.

Nothing should be hard-coded in the generated files. Are you sure you're adding a "service reference" and not an old-style "web reference"?

Upvotes: 1

Related Questions