Quantcast
Channel: Chilkat Forum - latest questions
Viewing all articles
Browse latest Browse all 1061

get data from webservice with x509

$
0
0

Hello,

I have to get data from a webservice (described as "like REST") , the site needs a certificate. We send some data in XML form but as contenttype text/plain (dont ask:-) ) and receive some data in XML form.

We have different certificates on the pc, so the one to be used comes from a file (see down)

In the next lines there is code from our working c# solution. But now need to do implement it in another project in VFP and want to use chilkat for it (which we use for ftp,..)

Can you give me a hint where to start or some code ?

Thanks a lot in advance tom

Here is the main part of the c# program :

namespace WebClientService

{ public class WebClient

{
    private readonly ILog _log;
    public WebClient()

    public string SendData(string uri, String xmlData)
    {

        var url = new Uri(uri);
        SecureWebClient client = new SecureWebClient();

       var response =client.UploadString(url, xmlData);

       _log.Debug(response);

        return response.ToString();

    }

    class SecureWebClient : System.Net.WebClient
    {

        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            X509Certificate myCert =  X509Certificate2.CreateFromCertFile("ClientCertificate.cer");
            request.ClientCertificates.Add(myCert);
            return request;
        }
    }

}

}


Viewing all articles
Browse latest Browse all 1061

Trending Articles