I have a project that has a service reference to a web service. Is there a way from the codebehind to get the actual http address of the service reference?
Thanks
You could retrieve it from the client proxy that was generated for you:
using (var client = new ServiceReference1.MyServiceClient("*"))
{
string address = client.Endpoint.Address.Uri.ToString();
}
or if you are having multiple endpoints in your config file:
using (var client = new ServiceReference1.MyServiceClient("MyService"))
{
var address = client.Endpoint.Address.Uri.ToString();
}
Yes, the generated proxy will have a Url
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With