我有一個IIS託管的WCF Web服務。它從兩個消費者開始。WCF端點。多個客戶端
1)在同一解決方案中測試WCF契約的IDE中的WinForm測試工具。
2)使用發佈版本的Asp.Net Web應用程序。
所有的開箱即可使用。
然後沿着第三名消費者,一個Android應用程序。爲了正確使用這個消息,必須用JSON WebGets和Webinvokes修飾WCF契約,並修改WCF Web.config以適應。
現在原來的兩位消費者不再工作。所以我需要改變Web.config和/或App.configs來獲得配置,其中所有三個工作。
首先關注IDE。我有WCF服務Web.Config的以下服務模型部分。
<system.serviceModel>
<client>
<endpoint binding="webHttpBinding" bindingConfiguration="JsonBinding"
contract="CouponParkingWCF.ICouponService" name="Json"
kind="" endpointConfiguration="">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:8707/CouponParking.svc"
binding="basicHttpBinding" contract="CouponParkingWCF.ICouponService"
name="BasicHttpBinding_ICouponService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" />
</basicHttpBinding>
<webHttpBinding>
<binding name="JsonBinding" />
</webHttpBinding>
</bindings>
<services>
<service name="CouponParkingWCF.CouponService">
<endpoint behaviorConfiguration="JsonBehavior" binding="webHttpBinding"
bindingConfiguration="" name="jsonEndPoint"
contract="CouponParkingWCF.ICouponService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="false" />
</system.serviceModel>
的WinForm的測試工具的App.config有:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8707/CouponParking.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttp"
contract="CouponParking.ICouponService"
name="BasicHttpBinding_ICouponService" />
</client>
</system.serviceModel>
我不是在配置終結點經驗豐富,上面已經基於實例和猜測。
當我運行測試工具WCF客戶端實例,但合同上的呼叫失敗:
There was no endpoint listening at http://localhost:8707/CouponParking.svc
that could accept the message. This is often caused by an incorrect address
or SOAP action. See InnerException, if present, for more details."
內部異常是:
{"The remote server returned an error: (404) Not Found."}
[System.Net.WebException]: {"The remote server returned an error: (404) Not Found."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
HResult: -2146233079
InnerException: null
Message: "The remote server returned an error: (404) Not Found."
Source: "System"
StackTrace: " at System.Net.HttpWebRequest.GetResponse()\r\n at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)"
TargetSite: {System.Net.WebResponse GetResponse()}
我將不勝感激一些指導我出錯了。
感謝
您是否試圖在相同的端點上向不同的客戶端(具有不同的需求 - 即綁定)公開相同的服務?如果是這樣,你不能那樣做。您需要爲不同的服務實現公開不同的端點。 – Tim
此外,你可以發佈配置文件,因爲它們*在添加第三個客戶端之前?它可能有助於瞭解它在工作時的狀態,以及它現在的狀態(不工作時)。 – Tim
每個服務器端端點具有**一個定義的綁定**你**不能擁有一個支持你的第一個和第二個客戶端的'basicHttpBinding'(SOAP)的單個端點,同時也支持Android客戶端的'webHttpBinding'(REST)。您需要爲此使用**兩個單獨的端點**。 –