Ok, I found the solution. When Visual Studio generates the wrapper classes for your service, the [ServiceName]SoapClient
has a constructor that takes a binding and an endpoint as a parameter. Define these and just pass them to the constructor.
Here is a pseudo-example.
void InitializeMyWebService(bool useSSLSite)
{
BasicHttpBinding b = useSSLSite ?
new BasicHttpBinding(BasicHttpSecurityMode.Transport) :
new BasicHttpBinding();
EndpointAddress e = useSSLSite ?
new EndpointAddress("https://www.example.com/svc/MyWebService.asmx") :
new EndpointAddress("http://intranet_server/svc/MyWebService.asmx");
myWebService = new MyWebServiceSoapClient(b, e);
}
}
MyWebService
will now work, as defined by the userSSLSite
parameter to our method.