我想從我的Silverlight應用程序中創建自託管的WCF服務,但它不起作用。該服務配置爲使用SSL,我可以使用WCFTestClient工具(一個Web瀏覽器)打開它,並且我可以引用該服務並在Silverlight項目中對其進行更新。當Silverlight應用程序試圖撥打電話到服務的問題是,它的炸彈,出現以下錯誤:無法在Silverlight應用程序中訪問自託管的wcf服務
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
當我打它使用WCF測試客戶端工具,它返回沒有問題的數據(預期) 。
任何想法?
下面是我的應用程序配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="6553600" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="6553600" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="Application.ServiceModel.ApplicationService" behaviorConfiguration="serviceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://192.168.1.171:8000/ApplicationServiceModel/service"/>
</baseAddresses>
</host>
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttp"
contract="Application.ServiceModel.IApplicationService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
<endpoint address="http://localhost:8000/"
binding="webHttpBinding"
contract="Application.ServiceModel.IApplicationService"
behaviorConfiguration="webHttpBehavior" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
謝謝!非常感謝!!! – spyter
問題,有沒有一種方法可以在使用xml的clientconfig文件中定義這個? – spyter
不,它是*服務器*決定它是否可以跨域方式調用,而不是客戶端調用(我假設您正在討論ServiceReferences.clientconfig文件)。這需要在服務器端完成。 – carlosfigueira