Note that there are some explanatory texts on larger screens.

plurals
  1. POInternal Server Error (500) when doing SOAP request
    text
    copied!<p>I am trying to do a SOAP request but the server is returning an 500 error. The SOAP request returns correctly the XML message via jmeter for example, so it must be something in my code, but i fail to see what. Can you help?</p> <pre><code>private void soapRequest(string regID) { string soapReq= @"&lt;?xml version=""1.0"" encoding=""utf-8""?&gt;"; soapReq= "&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:mpc=\"urn://mobility-platform.de/mpcustomerdb/\"&gt;\n"; soapReq += "&lt;soapenv:Header/&gt;\n"; soapReq += "&lt;soapenv:Body&gt;\n"; soapReq += "&lt;mpc:findRegistrationByID&gt;\n"; soapReq += "&lt;registrationID&gt;" + regID + "&lt;/registrationID&gt;\n"; soapReq += "&lt;/mpc:findRegistrationByID&gt;\n"; soapReq += "&lt;/soapenv:Body&gt;\n"; soapReq += "&lt;/soapenv:Envelope&gt;"; //Builds the connection to the WebService. HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://url?wsdl"); req.Credentials = new NetworkCredential("user", "pass"); req.Headers.Add("SOAP:Action"); req.ContentType = "text/xml;charset=\"utf-8\""; req.Accept = "text/xml"; req.Method = "POST"; //Passes the SoapRequest String to the WebService using (Stream stm = req.GetRequestStream()) { using (StreamWriter stmw = new StreamWriter(stm)) { stmw.Write(soapReq.ToString()); } } try { //Gets the response HttpWebResponse soapResponse = (HttpWebResponse)req.GetResponse(); //Writes the Response Stream responseStream = soapResponse.GetResponseStream(); //read the stream XmlDocument soapResponseXML = new XmlDocument(); StreamReader responseStreamRead = new StreamReader(responseStream); soapResponse.ContentType = "text/xml"; //MessageBox.Show(responseStreamRead.ReadToEnd().ToString()); string soapURL = responseStreamRead.ReadToEnd().ToString(); soapResponseXML.LoadXml(soapURL); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } </code></pre> <p>Here is the soap request</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mpc="urn://mobility-platform.de/mpcustomerdb/"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;mpc:findRegistrationByID&gt; &lt;registrationID&gt;2304580&lt;/registrationID&gt; &lt;/mpc:findRegistrationByID&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p><strong>Later edit:</strong> If i change <br> <code>req.Headers.Add("SOAP:Action");</code> to: <br> <code>req.Headers.Add("SOAPAction", ""\"http://url\"" + "findRegistrationByID");</code> i get an different error: <strong>"This property is not implemented by this class"</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload