Not able to add HTTPS enabled WCF Service as Service reference in Visual Studio 2010 IDE

六月ゝ 毕业季﹏ 提交于 2021-01-27 05:42:57

问题


While adding a HTTPS enabled WCF Service as Service reference through Visual Studio 2010 IDE, the following exception occured

There was an error downloading 'https://abc.cloudapp.net/DataService.svc'. The request failed with HTTP status 403: Forbidden. Metadata contains a reference that cannot be resolved: 'https://abc.cloudapp.net/DataService.svc'. The HTTP request was forbidden with client authentication scheme 'Anonymous'. The remote server returned an error: (403) Forbidden. If the service is defined in the current solution, try building the solution and adding the service reference again.

Please suggest me a solution for this.


回答1:


Another possible solution is to make sure that Visual Studio knows which certificate to use by setting it in credential manager.

Open credential manager and under Certificate-Base credentials click Add a certificate-based credential.

Enter the URL of your service reference and select the certificate from the store.




回答2:


The issue is the metadata binding. You must allow https GET to use the same URL for metadata and the service itself.

<serviceMetadata httpsGetEnabled="true" />

This will allow WCF to serve the metadata over HTTPS.




回答3:


I had encountered this issue earlier, try adding http://abc.cloudapp.net/DataService.svc (that's correct without https) and once the the service is added, make the change in web.config file from http to https.




回答4:


Can you access https based URL on IE and get WSDL? If you can get WSDL in IE without any problem then you do have certificate installed in your machine and VS somehow not able to use the client certificate and return this error. IF you can not get WSDL in your machine, then you need to install client certificate in your machine first and try again.

IF you want to workaround this issue with Visual Studio, you can use your IE to get the HTTPs WCF service metadata wsdl page and save WSDL on your local machine. After that open VS2010 and when you select "Add ServiceReference", route to saved WSDL metadata file on your machine, this way a Proxy Class for your Secure WCF service will be generated and you can still use it.




回答5:


My issue got resolved by adding my certificate into Browser.

Open Internet Explorer --> Internet Options --> Go to Content --> Click on Certificate --> Import your certificate into Personal Or Trusted Publisher

Then Try to consume the WCF Service, it will warn you a message but click OK, this will resolve the issue.

If it does not resolved, import the same certificate in Server under personal or Trusted people



来源:https://stackoverflow.com/questions/11168154/not-able-to-add-https-enabled-wcf-service-as-service-reference-in-visual-studio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!