PowerBuilder
PowerBuilder
Duplicate TLS 1.2 SOAP Request that uses .NET HttpWebRequest
See more HTTP Examples
This example shows how to duplicate a SOAP request that uses .NET's HttpWebRequest and requires TLS 1.2.
string xmlRequest = "...envelope..."
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
string url = "https://www3.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "text/xml;charset=UTF-8";
byte[] reqBytes = new System.Text.UTF8Encoding().GetBytes(xmlRequest);
req.ContentLength = reqBytes.Length;
try {
using (System.IO.Stream reqStream = req.GetRequestStream()) {
reqStream.Write(reqBytes, 0, reqBytes.Length);
reqStream.Flush();
reqStream.Close();
}
} catch (Exception ex) {
actionLogger.AddError(ex.Message, null);
actionLogger.Validate();
}
string xmlResponse = null;
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) {
try {
using (System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream())) {
xmlResponse = sr.ReadToEnd();
sr.Close();
}
} catch (Exception ex) {
actionLogger.AddError(ex.Message, null);
actionLogger.Validate();
} finally {
resp.Close();
}
}
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Req
string ls_XmlRequest
oleobject loo_Resp
string ls_XmlResponse
li_Success = 0
// This example assumes Chilkat HTTP to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.HttpVerb = "POST"
loo_Req.ContentType = "text/xml"
loo_Req.SendCharset = 1
loo_Req.Charset = "utf-8"
loo_Req.Path = "/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL"
ls_XmlRequest = "...SOAP envelope..."
loo_Req.LoadBodyFromString(ls_XmlRequest)
loo_Http.FollowRedirects = 1
// Chilkat will automatically offer TLS 1.2. It is the server that
// chooses the TLS protocol version. Assuming the server wishes to use
// TLS 1.2, then that is what will be used.
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpSReq("www3.gsis.gr",443,1,loo_Req,loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
destroy loo_Resp
return
end if
ls_XmlResponse = loo_Resp.BodyStr
Write-Debug ls_XmlResponse
destroy loo_Http
destroy loo_Req
destroy loo_Resp