1

我的网络服务命名空间有问题。它在我的计算机上运行良好,但是当我将其上传到团队基础服务器时,它对其他人不起作用。

我在网络服务中的代码(位于其自己的应用程序的“Sentry.SAID”命名空间中:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports Sentry.SAID.Core
Imports Sentry.SAID.Web

<System.Web.Services.WebService(Namespace:="http://localhost")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Powerbeatws
    Inherits System.Web.Services.WebService

“Sentry.SAID”命名空间中“Sentry.SAID.Web”应用程序中的 XML 文件

        <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="PowerbeatwsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="11000000" maxBufferPoolSize="524288"
         maxReceivedMessageSize="11000000"
         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://localhost:62862/Powerbeatws.asmx" binding="basicHttpBinding"
       bindingConfiguration="PowerbeatwsSoap" contract="PowerbeatSR.PowerbeatwsSoap"
       name="PowerbeatwsSoap" />
    </client>
  </system.serviceModel>

如果我将端点地址更改为 localhost/Powerbeatws.asmx,则会引发错误。有什么想法可以让我使用 localhost 在单独的计算机上工作吗?

目前,要使其在任何其他计算机上工作,必须添加新的服务参考。

4

1 回答 1

0

对于 Web 服务,我们必须记住涉及 2 个实体,托管的服务和使用它的客户端。

如果两者都在其绑定中使用 localhost,则它们必须假定相同的端口号,或者从 TFS 下载您的代码的人必须将端点绑定从 localhost:62862 更改为服务在其机器上运行的任何端口。

您也可以通过 Web 服务上的配置或通过每个人都使用众所周知的端口(例如 51000)的代码来创建特定的托管地址。将端点绑定更改为 localhost:51000 并确保服务主机正在侦听端口 51000 和它应该可以正常工作。

我认为问题在于团队没有在其本地主机上使用相同的端口号,因此绑定不起作用。它可以在您的机器上运行,因为您将服务托管在端口 62862 上。

虽然可能是错的。不确定他们看到了什么异常,但这在共享 Web 服务代码时并不少见。

于 2012-10-12T17:44:30.090 回答