(500) Internal Server Error on IronPython
I tried to use IronPython to create a SOAP request to a Web Service but got an Internal Server Error.
The same script has been tested from C# withouth error. Anyone got a clue?
Following is the ironpython command:
1: IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4927
2: Type "help", "copyright", "credits" or "license" for more information.
3: >>> from System.Net import *
4: >>> from System.Text import *
5: >>> from System.IO import *
6: >>> query = Encoding.UTF8.GetBytes('''<?xml version="1.0" encoding="utf-8"?>
7: ... <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns
8: :xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://www.w3.org/2003/05
9: /soap-encoding" xmlns:tns="http://www.witsml.org/wsdl/120" xmlns:types="http://w
10: ww.witsml.org/wsdl
11: ... <soap12:Body soap12:encodingStyle="http://www.w3.org/2003/05/soap-encoding
12: ">
13: ... <q3:WMLS_GetVersion xmlns:q3="http://www.witsml.org/message/120" />
14: ... </soap12:Body>
15: ... </soap12:Envelope>''')
16: >>> req = WebRequest.Create("http://localhost:81/Petrolink.Powerstore.Webservice
17: /wmls.asmx")
18: >>> req.Headers.Add("SOAPAction", "\"\"")
19: >>> req.Credentials = NetworkCredential("fred", "derf");
20: >>> req.ContentType = "application/soap+xml; charset=utf-8"
21: >>> req.Accept = "text/xml"
22: >>> req.Method = "POST"
23: >>> requestStream = req.GetRequestStream()
24: >>> requestStream.Write(query,0,query.Length)
25: >>> requestStream.Close()
26: >>> response = req.GetResponse()
27: Traceback (most recent call last):
28: File "<stdin>", line 1, in <module>
29: SystemError: The remote server returned an error: (500) Internal Server Error.
30:
And below is the C# code with the screenshot of the result:
1: byte[] query = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:tns=\"http://www.witsml.org/wsdl/120\" xmlns:types=\"http://www.witsml.org/wsdl/120/encodedTypes\" xmlns:rpc=\"http://www.w3.org/2003/05/soap-rpc\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body soap12:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"><q3:WMLS_GetVersion xmlns:q3=\"http://www.witsml.org/message/120\" /></soap12:Body></soap12:Envelope>");
2:
3: HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:81/Petrolink.Powerstore.Webservice/wmls.asmx");
4: // if SOAPAction header is required, add it here...
5: req.Headers.Add("SOAPAction", "\"\"");
6:
7: req.Credentials = new NetworkCredential("fred", "derf");
8: req.ContentType = "application/soap+xml; charset=utf-8";
9: req.Accept = "text/xml";
10: req.Method = "POST";
11:
12: Stream requestStream = req.GetRequestStream();
13: requestStream.Write(query,0,query.Length);
14: requestStream.Close();
15: WebResponse response = req.GetResponse();
16:
17: StreamReader sr = new StreamReader(response.GetResponseStream());
18:
19: Console.WriteLine(sr.ReadToEnd());
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
