在 VS2012 中添加 Web 服务引用时出错 [英] Error when adding web service reference in VS2012

查看:45
本文介绍了在 VS2012 中添加 Web 服务引用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 VS2012 中的新项目添加对 Web 服务的引用.我不断收到以下错误:

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

下载时出错'ServiceAddress/ConfigurationMgmt.wsdl/_vti_bin/ListData.svc/$metadata'.请求失败,HTTP 状态为 400:错误请求.元数据包含无法解析的引用:'ServiceAddress/ConfigurationMgmt.wsdl'.HTTP请求是未经授权使用客户端身份验证方案匿名".这从服务器收到的身份验证标头是基本"领域 =CASM"'.远程服务器返回错误:(401)未经授权.如果在当前解决方案中定义了该服务,请尝试构建解决方案并再次添加服务引用.

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.

更令人困惑的部分是我能够使用 VS2010 添加和使用对同一 Web 服务的引用.如果我在 VS2012 中打开 VS2010 项目并尝试更新服务引用,则会出现相同的错误.

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.

我尝试在 VS2012 中添加对新项目的服务引用,在管理员模式下启动 VS2012 并重新启动我的电脑.

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

我还尝试在 VS2012 项目中添加对我们 Intranet 上可用的其他服务的引用,它们似乎工作正常.

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?

推荐答案

我发现导致这种情况的一个可能原因是 VS2012 在允许访问 wsdl 之前尝试对安全代理进行身份验证.

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.

>

为了解决这个问题,我开始使用命令行 wsdl.exe 工具来生成 Web 服务数据类型.之后我就没有再犯错误了.

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.

对于 .Net 4.0,它可以在C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\wsdl.exe"中找到

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"

使用它从 wsdl 文件自动生成类型的示例:

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

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

这篇关于在 VS2012 中添加 Web 服务引用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆