【问题标题】:ASP.net Webservice *.asmx access with WCF Service ReferenceASP.net Webservice *.asmx 访问与 WCF 服务参考
【发布时间】:2015-01-04 15:37:46
【问题描述】:

假设我有一个 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."}

翻译

{"HTTP 请求未经授权,客户端身份验证方案为“匿名”。从服务器收到的身份验证标头为 'Basic realm=\"WebsitePanel Enterprise Server\"'"}

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

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

【问题讨论】:

  • 我的问题是“基本 HTTP 身份验证” 你能告诉我们一个具体的错误消息或类似的东西吗?通常可以通过 Add Service Reference 添加 asmx-services。
  • 我发布了德语错误消息并尝试翻译它
  • 在使用添加服务引用对话框或尝试运行代码时是否已经抛出异常?

标签: c# asp.net iis


【解决方案1】:

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

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

【讨论】:

  • 抛出了一些异常:(
  • *.config 文件中的附加行有效.. 谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-09
  • 1970-01-01
  • 2023-04-09
  • 1970-01-01
  • 2014-12-29
  • 1970-01-01
相关资源
最近更新 更多