Confused -> Silverlight 4 not allowing me to consume a WCF service using BasicHttpBinding?
OK I am totally confused and hopefully I am missing something here totally obvious. I am consuming a WCF service of mine (which is stable and working in ASP.NET) hosted in a Windows Service which uses a 'BasicHttpBinding' configuration. When I try to consume it from a Silverlight 4 application I get the following error in VS.NET:
*"Custom tool warning: Endpoint 'BasicHttpBinding_IMyService' at address 'https://mywcfservice:8000/WCFServices/MyService' is 开发者_Go百科not compatible with Silverlight 4. Skipping... MyService\Reference.svcmap"*
What!? I know and have gone through the hoops to jump through for making a netTCPBinding which has issues get past the error above in SL4, but why in the world is BasicHttpBinding having any issue with SL4? I thought since like day 1 of SL2 BasicHttpBinding was the defacto and easiest binding for Silverlight to consume. Here is my WCF server configuration:
<service behaviorConfiguration="ServiceBehavior" name="MyService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpWindowsBinding"
contract="IMyService"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://mywcfservice:8000/WCFServices/MyService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpWindowsBinding"
maxReceivedMessageSize="214748"
messageEncoding="Mtom"
transferMode="Streamed">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
What am I missing here? If anyone can help me or guide what might be incoorect please let me know. Thanks!
Edit: I think I might be on the trail - this service uses a 'Message Contract' as a parameter in a method and I wonder if this is causing any issues. However from this MSDN article: "Message contracts are supported in Silverlight 4" http://msdn.microsoft.com/en-us/library/cc896571(v=vs.95).aspx so I am still not 100% sure. I check 'Always generate message contracts' when consuming but it made no difference.
There are a few special attributes/values you use in your configuration file:
The BasicHttpWindowsBinding has transferMode and messageEncoding set to non default values.
According to WCF service for Sl3, which registered similar problems, you should do the following:
messageEncoding="Mtom"
Try: messageEncoding="Text" instead.
or transferMode="StreamedResponse"
Try: transferMode="Buffered" instead.
If you try these steps, you will probably get a running situation and can build in specifics from that point on, making sure it keeps working for the SL-WCF connection.
精彩评论