且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将服务引用添加到WCF客户端Web服务需要客户端身份验证证书

更新时间:2023-01-12 23:05:55

我假设你正在使用的服务进行客户端SSL验证。

I'm assuming that the service you are using is performing client SSL authentication.

由于添加服务引用失败,你可以使用 SvcUtil工具生成WSDL文件客户端,你有。我觉得语法会是这样的:

Since add service reference is failing, you can use svcutil to generate the client from the WSDL file that you have. I think the syntax would be something like:

svcutil *.wsdl /l:C# /out:Reference.cs /config /s /ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version35 /n:*,<NameOfYourNamespaceHere> /edb

这将生成一个文件,Reference.cs,包含代理类业务(你可以给这个文件任何你想要的名称)。这个文件添加到项目中。一个配置文件,output.config,也将产生。您可以将此配置添加到您的应用程序配置,而不​​是手动输入所有中。

This will generate a file, Reference.cs, that contains the proxy classes to the service (you can give this file whatever name you want). Add this file to your project. A config file, output.config, will also be generated. You can add this configuration to your application configuration instead of typing it all in by hand.

现在您可以按照此MSDN文章使用交通运输安全与证书认证一>。您可以向下跳到客户端部分,在那里它显示了如何将证书附加到code的要求,以及在配置中。

Now you can follow this MSDN article on using Transport Security with Certificate Authentication. You can skip down to the client section where it shows how to attach the certificate to the request in code as well as in configuration.

祝你好运。