网站代码无法连接到同一服务器上的肥皂服务

发布于 2024-12-13 12:08:05 字数 1854 浏览 0 评论 0原文

我的 ASP.NET 网站从 App_Code 中的代码调用 .net 服务来检索一些信息。

Web 服务托管于 http://mydomain/ws/DirectoryService.asmx

每当我在托管所需 .net 服务的同一服务器以外的任何服务器上部署网站时,一切都运行良好。

每当我将站点部署到托管 Web 服务的同一 Web 服务器时,都会收到 401.1 错误。

我在网站的 web.config 中定义了以下绑定:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="LR Directory ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://mydomain/ws/DirectoryService.asmx" binding="basicHttpBinding" bindingConfiguration="LR Directory ServiceSoap" contract="ExpertsServiceReference.LRDirectoryServiceSoap" name="LR Directory ServiceSoap" />
    </client>
  </system.serviceModel>

显然,问题出在该绑定上。它无法在同一服务器内工作。如何解决这个问题?

PS 如果我注释掉 web.config 中的绑定,网站可以正常加载,但功能不完整,因为它无法连接到服务。

更新:一个非常重要的细节:我的目标网站和 .net 服务都位于同一台服务器、同一 IIS 上,但绑定到不同的外部 IP 地址,因此问题不可能出现在网络访问字段中。

另外,如果我将网站的身份验证模式从“匿名”设置为“Windows”,则一切正常,但每次访问该网站时都需要提供 Windows 凭据。

My ASP.NET web site calls a .net service from a code in App_Code to retrieve some information.

The web service is hosted at http://mydomain/ws/DirectoryService.asmx.

Whenever I deploy a web site on any server other then the same server that the required .net service is hosted on, everything works good.

Whenever I deploy the site to the same web server, that the web service is hosted on, I get 401.1 error.

I have the following binding defined in web.config of the site:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="LR Directory ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://mydomain/ws/DirectoryService.asmx" binding="basicHttpBinding" bindingConfiguration="LR Directory ServiceSoap" contract="ExpertsServiceReference.LRDirectoryServiceSoap" name="LR Directory ServiceSoap" />
    </client>
  </system.serviceModel>

Apparently, the problem lies in that binding. It can't work from within the same server. How can the problem be fixed?

P.S. If I comment out the binding in web.config, the web site loads fine, but it is not fully functional, since it can't connect to a service.

UPDATE: A very important detail: My target web site and a .net service are both located on the same server, same IIS, but are bound to a different external IP addresses, so the problem can't be in a network access field.

Also, If I set the authentication mode of the web site from Anonymous to Windows, everything works fine, but I need to provide a windows creds each time I access the site.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若相惜即相离 2024-12-20 12:08:05

问题解决了。事实证明,我需要编辑匿名身份验证设置,以便在使用时(在我的情况下总是如此),代码将在应用程序池的身份下,而不是 IUSR 下:
在此处输入图像描述

Problem solved. It turned out that I needed to Edit an anonymous authentication settings, so that when used (in my case it is always), the code would go under application pool's identity, and not IUSR:
enter image description here

巷雨优美回忆 2024-12-20 12:08:05

确保您在不同的端口上运行网络服务和网站,并确保您的配置反映了正确的端口。

如果您在同一端口上运行两个网站(默认情况下,这将是端口 80,为 HTTP 保留),它们将相互冲突 - 其中一个将获得该端口,另一个则不会。

假设您将 Web 服务端口更改为 8080,您可以将站点配置为使用端点:

address="http://mydomain:8080/ws/DirectoryService.asmx"

Ensure you are running the webservice and website on different ports, and make sure your configuration reflects the correct port.

If you are running two websites on the same port (by default this would be port 80, reserved for HTTP), they will conflict with each other - one of them will get the port, the other will not.

Say you change the web service port to 8080, you would configure the site to use the endpoint:

address="http://mydomain:8080/ws/DirectoryService.asmx"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文