【发布时间】:2016-09-07 23:38:26
【问题描述】:
我有一个自托管 WCF 服务,如下所示:
[ServiceContract]
public interface IService {
[OperationContract]
[WebGet]
List<Data> GetData();
//...and much more Methods
}
我的 App.config 如下所示:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="MetaInformation">
<serviceMetadata httpGetEnabled="true"
httpGetUrl="http://localhost:8500/MetaInfo"
httpsGetBinding="" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpointBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetaInformation" name="Library.WcfService.ServiceModel">
<endpoint address="http://localhost:8500/Service"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBindingSettings"
contract="Library.WcfService.IService"
bindingName="BasicHttpBindingSettings"
behaviorConfiguration="EndpointBehavior"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBindingSettings"
closeTimeout="00:50:00"
openTimeout="00:50:00"
sendTimeout="00:50:00"
maxBufferSize="524288"
transferMode="Streamed"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647"
messageEncoding="Text">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.web>
<httpRuntime maxRequestLength="102400"/>
</system.web>
当我在本地计算机上运行此服务器和客户端应用程序时,它运行良好。 但是当我尝试在另一台 PC 上运行服务器应用程序时,我无法在客户端添加服务引用,因为我得到了这个:
405 Method not allowed 元数据包含无法解析的引用:“http://192.168.178.54:8500/MetaInfo”。这不是一个 收听http://192.168.178.54:8500/MetaInfo端点在场谁 可以接受消息。这通常是由不正确的 地址或 SOAP 操作
我几乎尝试了我在互联网上找到的所有东西,但没有任何效果。 切换到 IIS 或使用其他协议应该是 B 计划,我想通过 http 保持它自托管。
请有人帮我解决这个问题。
【问题讨论】:
-
您能否告诉我们另一台计算机上安装了哪个 .NET 版本,以及您是否将 .NET 未提供的所有必需 dll(来自每个类中的使用)复制到另一台计算机的 WCF-bin 文件夹中?可能是未安装 ether .NET(在所需的最小版本中),或者您的 GAC(全局程序集缓存)中有其他计算机没有的东西。
-
我在两台机器上都使用 .NET 4.0。我刚刚将整个 VS 解决方案复制到另一台 PC 进行调试。当我在另一台 PC 上运行客户端时,它也可以工作。仅当我尝试通过 LAN 使用 WCF 服务时才会收到此错误。