1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
String soapRequest = ESBManager.Read(TPL.SOAP_REQUEST);
soapRequest = String.Format(soapRequest, orderRequest);
byte[] buffer = Encoding.ASCII.GetBytes(soapRequest);
X509Certificate Cert = X509Certificate.CreateFromCertFile(Configuration.GetConfigurationVariable("esb.certificate"));
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("https://xxxx");
WebReq.ClientCertificates.Add(Cert);
//The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
// Elargissement du timeout
WebReq.Timeout = 300000;
//Set the method/action type
WebReq.Method = "POST";
//We use form contentType
WebReq.ContentType = "soap/xml; charset=utf-8";
//The length of the buffer
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the post data
Stream MyPostData = WebReq.GetRequestStream();
//Now we write, and after wards, we close. Closing is always important!
MyPostData.Write(buffer, 0, buffer.Length);
MyPostData.Close();
//Get the response handle, we have no true response yet!
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
//Now, we read the response (the string), and output it.
Stream MyResponse = WebResp.GetResponseStream();
StreamReader MyResponseReader = new StreamReader(MyResponse);
//Read the response Stream and write it
String response = MyResponseReader.ReadToEnd();
return response; |
Partager