Error when adding web service reference in VS2012

回眸只為那壹抹淺笑 提交于 2019-12-13 07:23:51

问题


I am trying to add a reference to a web service for a new project in VS2012. I keep getting the below error:

There was an error downloading 'ServiceAddress/ConfigurationMgmt.wsdl/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: 'ServiceAddress/ConfigurationMgmt.wsdl'. The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="CASM"'. The remote server returned an error: (401) Unauthorized. If the service is defined in the current solution, try building the solution and adding the service reference again.

The part that more confusing is that I am able to add and use a reference to the same web service using VS2010. If I open the VS2010 project in VS2012 and try to update the service reference I get the same error.

I have tried adding the service reference to new projects in VS2012, starting VS2012 under admin mode and restarting my pc.

I have also tried adding references to other services in VS2012 project that are available on our intranet and they seem to work fine.

Is there something basic that I am missing here? What else can I try to find out the reason behind this problem?


回答1:


Change the web.config file in security tag,

<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Anonymous"/>
    <message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>

i think this will hep you. if its not working then there is problem in your service provider deployment ACL




回答2:


I found that one possible reason that could be causing this was VS2012 trying to authenticate to the security proxy before it was allowed to get access to the wsdl.

To get around it, I started using the command line wsdl.exe tool to generate the web service data types. After that I did not have any more errors.

For .Net 4.0 it can be found at ""C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\wsdl.exe"

example of using it to auto generate types from a wsdl file:

wsdl /l:CS YourWebservice.wsdl /pu:username /pp:password /pd:yourFirmDomain.com Common.xsd xmlmime.xsd



来源:https://stackoverflow.com/questions/19433452/error-when-adding-web-service-reference-in-vs2012

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