views:

1326

answers:

1

I have an ASP.NET webpage that has a web reference to a SOAP WSDL. If I call the methods associated with this WSDL (the methods live on another server), everything works fine. However, I'd like to be able to dynamically change the endpoint address where the WSDL points. The reason being that we host the same set of web services for different groups and we like to track who's using the web services. So, each set has its own URL.

I tried changing the "Url" property on my soap client object to a different endpoint, but when I do, the methods return this error:

Client found response content type of 'text/plain', but expected 'text/xml'

I'm thinking that the Url property confuses the proxy class into thinking that I'm now using a REST web service?

Here's some of my code:


mySoapNamespace.mySoapClient soapClient = new mySoapNamespace.mySoapClient();

//next I try to change the endpoint URL of the WSDL, misguided? ...
soapClient.Url = "http://a_different_url/my_soap_server.wsdl";
string result = soapClient.myTestMethod(); 
Response.Write(result);


And that's where I get the error. Does anyone know a fix or a different way to dynamically change the endpoint of a SOAP call?

+1  A: 

Okay! I figured out what I was doing wrong. When I change the Url property of my web reference, I need to specify the code endpoint (the thing that's the soap:address in the wsdl:port section of the WSDL). I was specifying the WSDL itself:

soapClient.Url = "http://a_different_url/my_soap_server.wsdl";

...when really, I should have been referencing the PHP script behind it.

soapClient.Url = "http://a_different_url/my_soap_server.php";

I can plainly see what the proxy class sets my Url to (when I import the WSDL), by looking at the web.config file. It has an appSettings section that lists the URL. And I noticed it was pointed at the code file, not the WSDL on the remote server.

Nick R.