POST /SimpleWebService.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://localhost/HelloWorld" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <HelloWorld xmlns="http://localhost" /> </soap:Body> </soap:Envelope>
dotNetXMLDoc := dotNetXMLDoc.XmlDocument(); dotNetHttpUtility := dotNetHttpUtility.HttpUtility(); XMLRequestString := '<?xml version="1.0" encoding="utf-8"?>'; XMLRequestString += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'; XMLRequestString += ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'; XMLRequestString += ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; XMLRequestString += ' <soap:Body>'; XMLRequestString += ' <HelloWorld xmlns="http://localhost" />'; XMLRequestString += ' </soap:Body>'; XMLRequestString += '</soap:Envelope>'; dotNetWebHeaders := dotNetWebHeaders.WebHeaderCollection(); dotNetHttpWebRequest := dotNetHttpWebRequest.CreateHttp('http://localhost/SimpleWebService.asmx'); dotNetHttpWebRequest.Method('POST'); dotNetHttpWebRequest.ContentType('text/xml'); dotNetHttpWebRequest.MediaType('text/xml'); dotNetWebHeaders.Add('SOAPAction','http://localhost/HelloWorld'); dotNetHttpWebRequest.Headers(dotNetWebHeaders); dotNetHttpWebRequest.ReadWriteTimeout(30); dotNetStreamOut := dotNetStreamOut.MemoryStream(); dotNetStreamOut := dotNetHttpWebRequest.GetRequestStream; dotNetStreamWriter := dotNetStreamWriter.StreamWriter(dotNetStreamOut); dotNetStreamWriter.Write(XMLRequestString); dotNetStreamWriter.Close(); dotNetWebResponse := dotNetHttpWebRequest.GetResponse; dotNetStreamIn := dotNetWebResponse.GetResponseStream; dotNetStreamReader := dotNetStreamReader.StreamReader(dotNetStreamIn); dotNetXMLDoc.LoadXml(dotNetStreamReader.ReadToEnd()); MESSAGE(dotNetXMLDoc.OuterXml);
dotNetWebResponse := dotNetHttpWebRequest.GetResponse;
Comments
The problem occured because setting the WebHeaderCollection to the HttpWebRequest removed all previously set headers.
So the "solution" was to set additional headers before setting the ContentType:
I do not know how manage the error with HttpWebRequest.GetResponse sentence. In my environment I have two databases that communicate each other using a web services. If I try to post some document and my web service return an error I want to manage this error and show it to the user but HttpWebRequest.GetResponse sentence return an internal error 500.
Anybody knows how manage it?
Thanks in advance.
A call to System.Net.HttpWebRequest.GetResponse failed with this message: The remote server returned an error: (500) Internal Server Error
is there any thing where i have to change in the above code thanks in advance
Regards
Mouli