خرید بک لینک

Vote count: 0

I try to send a SOAP EnvelopXMl to a Web Service with a certificate file (certificate.p12). I have this following class to manage it :

 public class SoapClientManager {
        private string _url;
        private string _envXml;

        public String Url {
            get {
                retu this._url;
            }

            set {
                this._url = value;
            }
        }
        public String EnvXml {
            get {
                retu this._envXml;
            }

            set {
                this._envXml = value;
            }
        }

        public string CallWebService() {
            HttpWebRequest request = CreateWebRequest(_url);
            XmlDocument soapEnvelopeXml = createEnveloppeXml(_envXml);
            using (Stream stream = request.GetRequestStream()) {
                soapEnvelopeXml.Save(stream);
            }

            using (WebResponse response = request.GetResponse()) {
                using (StreamReader rd = new StreamReader(response.GetResponseStream())) {
                    string soapResult = rd.ReadToEnd();
                    retu soapResult;
                }
            }
        }

        private HttpWebRequest CreateWebRequest(string url) {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.Headers.Add(@"SOAP:Action");
            webRequest.ContentType = "text/xml;charset="utf-8"";
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";
            webRequest.ClientCertificates.Add(new X509Certificate2(@"D:cetificate.p12", "password"));
            retu webRequest;
        }

        private XmlDocument createEnveloppeXml(string envXml) {
            XmlDocument soapEnvelop = new XmlDocument();
            soapEnvelop.LoadXml(envXml);
            retu soapEnvelop;
        }

    }

After calling WS , i have this folowing error :

enter image description here

TEsting with SOAPUI , I can easily to use the WEb Service with the certificate file and password. réf : http://www.codeproject.com/Articles/426121/Send-a-private-client-certificate-p-in-HTTP-Post Thanks for your help.

asked 20 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 17 تير 1395 ساعت: 21:03

صفحه بندی