c# - ASP.net Webservice *.asmx 访问与 WCF 服务引用

标签 c# asp.net iis

假设我有一个 ASP.net Web 服务。带有 *.asmx-Files 的旧版本。在 IIS 8 上运行

当我尝试使用 WCF 服务客户端在 Visual Studio 中通过“添加服务引用”访问它时,它不起作用。

我的问题是“基本 HTTP 身份验证”..

错误信息

{"Die HTTP-Anforderung ist beim Clientauthentifizierungsschema \"Anonymous\" nicht autorisiert. Vom Server wurde der Authentifizierungsheader \"Basic Realm=\"WebsitePanel Enterprise Server\"\" empfangen."}

已翻译

{"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=\"WebsitePanel Enterprise Server\"'"}

当我使用“网络引用”时,它确实有效。 [我正在使用 WebsitePanel 并尝试访问其企业服务器 Web 服务(asmx 文件)]

是否可以将旧的 ASMX-Web 服务与“WCF 服务引用”-Clients 一起使用? 有人可以解释差异,我应该使用什么吗?

最佳答案

根据对您问题的评论,我假设您忘记提供一些身份验证信息。通过在代理对象中提供有效的用户名和密码,您应该能够调用该服务:

client.ClientCredentials.UserName.UserName = "foo";
client.ClientCredentials.UserName.Password = "bar";
client.SomeMethod();

此外,您应该确保将配置设置为 Transport(或 TransportCredentialOnlyclientCredentialType="Basic"):

<bindings>
  <basicHttpBinding>
    <binding name="myBinding">
      <security mode="Transport">
        <transport clientCredentialType="Basic" proxyCredentialType="None" realm="WebsitePanel Enterprise Server" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

要获取更详细的错误信息,请配置跟踪:http://msdn.microsoft.com/en-us/library/ms733025%28v=vs.110%29.aspx

关于c# - ASP.net Webservice *.asmx 访问与 WCF 服务引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27767142/

相关文章:

c# - 为什么重启IIS/应用程序池回收时静态变量数据丢失而不是实例?

c# - 如何模拟作为接口(interface)的接口(interface)属性

c# - 如何使用 Mono Cecil 更改字段值?

c# - 根据该键的属性确定字典是否包含该键?

c# - 将youtube播放列表嵌入网页中

windows - 我可以在同一台服务器上安装、删除和重新安装相同的 SSL 证书吗

c# - Spin 在 Portable Class Library 中等待多次自旋

javascript - asp.net 使用 javascript 打印页面

c# - 如何从 Angular Reactive Form 接收文件上传?

iis - 拒绝基于IP地址访问IIS 7.0中的.axd