简体   繁体   English

在VS2012中添加Web服务引用时出错

[英]Error when adding web service reference in VS2012

I am trying to add a reference to a web service for a new project in VS2012. 我正在尝试为VS2012中的新项目添加对Web服务的引用。 I keep getting the below error: 我不断收到以下错误:

There was an error downloading 'ServiceAddress/ConfigurationMgmt.wsdl/_vti_bin/ListData.svc/$metadata'. 下载“ ServiceAddress / ConfigurationMgmt.wsdl / _vti_bin / ListData.svc / $ metadata”时出错。 The request failed with HTTP status 400: Bad Request. 请求失败,HTTP状态为400:错误的请求。 Metadata contains a reference that cannot be resolved: 'ServiceAddress/ConfigurationMgmt.wsdl'. 元数据包含无法解析的引用:“ ServiceAddress / ConfigurationMgmt.wsdl”。 The HTTP request is unauthorized with client authentication scheme 'Anonymous'. 客户端身份验证方案“匿名”未授权HTTP请求。 The authentication header received from the server was 'Basic realm="CASM"'. 从服务器收到的身份验证标头是“ Basic realm =“ CASM”“。 The remote server returned an error: (401) Unauthorized. 远程服务器返回错误:(401)未经授权。 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. 更令人困惑的部分是,我能够使用VS2010添加和使用对同一Web服务的引用。 If I open the VS2010 project in VS2012 and try to update the service reference I get the same error. 如果我在VS2012中打开VS2010项目并尝试更新服务引用,则会遇到相同的错误。

I have tried adding the service reference to new projects in VS2012, starting VS2012 under admin mode and restarting my pc. 我尝试将服务引用添加到VS2012中的新项目中,在管理员模式下启动VS2012并重新启动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. 我还尝试过添加对VS2012项目中其他服务的引用,这些引用在我们的Intranet上可用,并且它们似乎可以正常工作。

Is there something basic that I am missing here? 我在这里缺少基本的东西吗? What else can I try to find out the reason behind this problem? 我还能尝试找出该问题背后的原因吗?

Change the web.config file in security tag, 更改安全标签中的web.config文件,

<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 如果它不起作用,那么您的服务提供商部署ACL中有问题

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. 我发现可能导致此问题的一个可能原因是VS2012在允许其访问wsdl之前尝试对安全代理进行身份验证。

To get around it, I started using the command line wsdl.exe tool to generate the web service data types. 为了解决这个问题,我开始使用命令行wsdl.exe工具生成Web服务数据类型。 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" 对于.Net 4.0,可以在““ 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文件自动生成类型的示例:

wsdl /l:CS YourWebservice.wsdl /pu:username /pp:password /pd:yourFirmDomain.com Common.xsd xmlmime.xsd wsdl / l:CS YourWebservice.wsdl / pu:用户名/ pp:密码/pd:yourFirmDomain.com Common.xsd xmlmime.xsd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM