WSDL中的安全头C#

时间:2017-03-30 11:06:12

标签: c# .net wsdl

我必须为WSDL创建一个客户端。但我一直在接受     "消息中没有安全标头,但政策要求。" 这是我的代码             USImportoerService服务=新的USImportoerService();             X509Certificate2 cert = new X509Certificate2(certPath,PASSWORD,X509KeyStorageFlags.MachineKeySet);             service.ClientCertificates.Add(CERT);             var result = ser.getUSKoeretoej(); 继承人App.config      <结构> < system.serviceModel>     <绑定>         < customBinding>             < binding name =" USImportoerService_Port">               < security authenticationMode =" CertificateOverTransport" securityHeaderLayout =" LaxTimestampLast" includeTimestamp ="真"             enableUnsecuredResponse ="真">               < /安全>                 < textMessageEncoding messageVersion =" Soap11" />                 < httpsTransport />             < /结合>         < / customBinding>     < /绑定>   <客户机GT;         < endpoint address =" HTTPS to WSDL"             结合=" customBinding" bindingConfiguration =" USImportoerService_Port"             合同=" ServiceReferenceUSImportoer.USImportoerServiceType"             命名="端口1" />     < /客户机GT; < /system.serviceModel> 希望有人能提供帮助

1 个答案:

答案 0 :(得分:0)

使用HttpClient调用SOAP服务

   USImportoerService service = new USImportoerService();
   X509Certificate2 cert = new X509Certificate2(certPath, PASSWORD, X509KeyStorageFlags.MachineKeySet);
    HttpClientHandler handler = new HttpClientHandler();
    handler.ClientCertificates.Add(cert);
    HttpClient client = new HttpClient(handler);
    // Call service using httpClient
    //var result = ser.getUSKoeretoej();

如何使用httpClient调用SOAP服务 Client to send SOAP request and receive response