【问题标题】:Web Service NamespaceWeb 服务命名空间
【发布时间】:2012-10-12 17:02:50
【问题描述】:

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

我在网络服务中的代码(位于其自己的应用程序的“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 在单独的计算机上运行它吗?

目前要让它在任何其他计算机上工作,必须添加一个新的服务引用。

【问题讨论】:

  • 假设他们在本地机器上的端口 62862 上运行您的服务,我认为应该可以工作......也许他们托管服务的服务端口号不同?
  • 每台机器的服务端口号变化。
  • 命名空间中的http://localhost与配置文件中的http://localhost:62862无关。它们完全不相关。

标签: .net vb.net web-services soap


【解决方案1】:

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

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

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

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

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

【讨论】:

    猜你喜欢
    • 2010-09-07
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 2010-10-05
    • 2011-02-22
    相关资源
    最近更新 更多