Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a project file which I have tested using SOAP UI.

enter image description here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
182 views
Welcome To Ask or Share your Answers For Others

1 Answer

SOAPAction is required in SOAP 1.1 but can be empty (""). See the comment here

First of all you should try to create new SOAP project using your link to wsdl file. After that try to do request from SOAP UI. Try to run "doCommand" action. Look at the result. Than you can compare it with request from your app. You can also use Fiddler to intersept your requests and compare them to find a difference.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...