Unable to playback the webtest having web service with client certificate (pfx) RRS feed

  • Question

  • Hi,

    I have created a webservice based webtest on Visual Studio 2012. The same soap request works fine on SOAPUI after adding the pfx certificate.

    However, I'm unable to get the webtest working even after creating the coded webtest and adding the client certificate. Below is the my code snippet. I am getting the 500 server error and output as "Rejected by policy. (from client)".  Appreciate if you can help me with this... Is this the right way to add the pfx certificate. How do I verify if the webtest is even picking it up correctly?

    Code Snippet for the Coded Webtest --

      public override IEnumerator<WebTestRequest> GetRequestEnumerator()
                WebTestRequest request1 = new WebTestRequest("https://*sample link.svc");
                request1.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate(@"C:\\Temp\\file-name.pfx", @"password"));//(@"<path and filename of cert file to use>, @"<password for cert>")); //This was the line I have added in my coded webtest
                request1.ThinkTime = 12;
                request1.Timeout = 60;
                request1.Method = "POST";
                request1.Headers.Add(new WebTestRequestHeader("Content-Type", "text/xml;charset=UTF-8"));
                request1.Headers.Add(new WebTestRequestHeader("SOAPAction", "\"Operation_FetchCase\""));
                StringHttpBody request1Body = new StringHttpBody();
                request1Body.ContentType = "text/xml;charset=UTF-8";
                request1Body.InsertByteOrderMark = false;
                request1Body.BodyString = @"<soapenv:Envelope xmlns:soapenv....... 

    soap body (cont)

              request1.Body = request1Body;
                yield return request1;
                request1 = null;

    Pradeep Mirchandani

    Friday, October 30, 2015 3:53 AM

All replies