我主持WCF服務,它看起來像這樣的自我:自託管的WCF服務拋出錯誤消息「不允許405方法」
[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方法包含無法解析的引用:「http://192.168.178.54:8500/MetaInfo 」。這是不是 收聽http://192.168.178.54:8500/MetaInfo端點禮物 可以接受的消息。這通常是由不正確的 地址或SOAP動作造成的
我嘗試了幾乎所有在互聯網上找到的東西,但都沒有成功。 切換到IIS或使用其他協議應該是一個計劃B,我想保持它自己與http託管。
請有人可以幫助我我絕望與這個問題。
你能否告訴我們在另一臺計算機上安裝了哪個.NET版本,以及如果你將所有需要的dll(從每個類中的使用)複製到另一臺計算機的WCF-bin文件夾?可能是以太網.NET沒有安裝(在所需的最小版本中),或者您的GAC(全局程序集緩存)中有另一臺計算機沒有的東西。 –
我在兩臺機器上都使用.NET 4.0。我只是將整個VS解決方案複製到其他PC進行調試。 當我在另一臺PC上運行客戶端時,它也可以工作。只有當我嘗試通過LAN使用WCF服務時,纔會出現此錯誤。 –