Thomas
Thomas

Reputation: 34208

how to dynamic binding of web service URL

i store web service url in web.config or app.config. when i call web service like

 ServiceAvailabilityTestClient.TestClient servAvailClient = new ServiceAvailabilityTestClient.TestClient();
servAvailClient.url= myapp.config url here.
servAvailClient.CallValidateCityPostalCodeZip();

the problem is the property called url is not appearing. sp please tell me what to do. i just add wsdl file location as service reference because web service path called not being added. web service url which i try to add as web service reference is

https://devwebservices.purolator.com/EWS/V1/ServiceAvailability/ServiceAvailabilityService.asmx

1) i just not being able why i am not being able to add this web service url as service reference

2) why url property is not exposed in client side.

can anyone guide me what is the matter. thanks

Upvotes: 1

Views: 742

Answers (2)

msjonathan
msjonathan

Reputation: 514

You could do it through your generated client or ChannelFactory:

var client = ChannelFactory(IWcfService).CreateChannel(Binding, ServiceModel.EndpointAdress)

or 

var client = New Client(binding, RemoteAdress)

EndpointAdress just takes string or uri in constructor e.g.http://yourservice.asmx

Upvotes: 1

tom redfern
tom redfern

Reputation: 31780

Are you using the <System.ServiceModel/> config section? If so you shouldn't have to do anything - the URL will be loaded from the <client/> section of the config when you create the channel.

Upvotes: 0

Related Questions