I have a project file which I have tested using SOAP UI.
Now I wanted to write it's client side so by viewing this solution I have tried to do things work. But I am having a problem.
In the solution, URL
and action
are mentioned. I have a URL
but I am not sure what is my action URL
. So I put both of the same.
var _url = "http://111.111.111.1:111/HES/services/DoCommandRequest";
var _action = "http://111.111.111.1:111/HES/services/DoCommandRequest";
XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
{
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
Console.Write(soapResult);
}
After running my code I am getting an exception at using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
which says
System.Net.WebException {"The remote server returned an error: (500) Internal Server Error."}
I believe that there is some problem with my action
, but I am not sure.
Any help would be highly appreciated.
See Question&Answers more detail:os