I am trying use a web service in a C# ASP.Net Web Application. The service is built in PHP and is located on some remote server not under my control so I cant modify it to add
Edit: Previously i got a 500 Internal server error because my soap string was not correctly formatted. I ananlyzed the xml being returned from the web service and built my soap string message by look at xml. Finally i got over the problem with help from Dan ^ & some bit of research over the internet. Thanks Dan.
I got over the 500 server error. Now i am able to get a response of login failure atleast...
public String MyWebServiceCall()
{
string strSoapMessage = ""
+ ""
+ " "
+ " "
+ " Support@foo.net "
+ " bar "
+ " "
+ " "
+ " ";
HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(@"https://subreg.forpsi.com/robot2/subreg_command.php/"));
req.ContentType = "text/xml; charset=UTF-8";
req.Method = "POST";
req.Accept = "text/xml";
req.Headers.Add("SOAPAction", @"https://subreg.forpsi.com/robot2/subreg_command.php/");
req.ProtocolVersion = HttpVersion.Version11;
req.Credentials = CredentialCache.DefaultCredentials;
//req.Credentials = new NetworkCredential("Support@foo.net", "bar");
StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
stm.Write(strSoapMessage);
stm.Flush();
stm.Close();
HttpWebResponse wr = (HttpWebResponse)req.GetResponse();
StreamReader srd = new StreamReader(wr.GetResponseStream());
string resulXmlFromWebService = srd.ReadToEnd();
return resulXmlFromWebService;
}
Now the next problem is to pass the correct credentials and process the response to do other stuff...
btw, here was the response....
false
Edit: The value false is Ok as i am sending in the wrong credentials. i call other functions of the web service in a similar fashion and was able to call all functions of the web service and retrieve the corresponding return values and then perform other processing.
Thanks all who helped contributing to solve the problem.
Regards