Reputation: 11
I'm developing a small project, that is an C# web service, i did that but now i want to run the web service using the protocol HTTPS, for that i have installed web authentication certificate in my system and my IIS 5.1 server is running under HTTPS protocol(i have configured in that directory security)
But now i want to invoke the web service using the HTTPS protocol, somebody told that, i need to modify the WSDL file for that web service but i don't know how to do it...
now my service url is like this.... http://localhost:2335/SWebService.asmx
here i would like to use https instead of http
Upvotes: 0
Views: 6686
Reputation: 13621
When you instantiate your web service proxy class you can override the URL of the web service using the Url parameter.
If you acquire your desired URL then you can set it here.
It would be advisable to acquire the desired URL from a config file and to set up a factory class that will serve up web service proxies.
MyWebService clientProxy = new MyWebService();
clientProxy.Url = "https://localhost:2335/SWebService.asmx";
// or better still
// clientProxy.Url = ConfigurationSettings.AppSettings["webServiceUrl"];
This approach is then useful for going live, because you will want a live web service endpoint.
Adding the factory class here:
public static class WebServiceFactory
{
public static MyWebService GetMyWebService()
{
MyWebService clientProxy = new MyWebService();
clientProxy.Url = ConfigurationSettings.AppSettings["webServiceUrl"];
return clientProxy;
}
}
means that you can then just get your client proxy like this:
MyWebService clientProxy = WebServiceFactory.GetMyWebService();
string exampleText = clientProxy.GetExampleText();
Here is an example of the web.config file:
<configuration>
<appSettings>
<add key="webServiceUrl" value="https://localhost:2335/SWebService.asmx" />
</appSettings>
Upvotes: 1