silverlight - Exposing WCF Service to Mobile Clients -


I have an existing ASP.NET web application. This ASP.NET web application uses JQuery to provide rich experience to users. This user interface interacts with the server through some WCF services. A sample service looks like:

Now I want to apply this service in an iPhone and a Windows Phone 7 application. In an effort to do this, I have configured the service as follows:

  & lt; System.serviceModel & gt; & Lt; Behavior & gt; & Lt; Endpoint beehaviors & gt; & Lt; Transaction name = "myServiceBehavior" & gt; & Lt; EnableWebScript / & gt; & Lt; / Behavior & gt; & Lt; / EndpointBehaviors & gt; & Lt; ServiceBehaviors & gt; & Lt; Transaction name = "" & gt; & Lt; ServiceMetadata httpGetEnabled = "true" /> & Lt; The services included in the debugging include exceptions = DishialInstine = "false" /> & Lt; / Behavior & gt; & Lt; / ServiceBehaviors & gt; & Lt; / Behavior & gt; & Lt; Service Hosting Environment ASPnet Compatibility Enabled = "True" Multiple SiteBindingsEnabled = "true" /> & Lt; Services & gt; & Lt; Service name = "myservice" & gt; & Lt; Endpoint address = "behavior" configuration = "myServiceBehavior" binding = "webHTPbinding" contract = "IMSI service" /> & Lt; / Services & gt; & Lt; / Services & gt; & Lt; /system.serviceModel>  

This service works with Jake Call in my ASP.NET web application. I have not started working on an iPhone client but when I try to get this service to my WP7 client, I have problems. As it stands now, when I launch my WP7 application, So I get an error which says:

  KeyNotFoundException  

If I change the bindings in the config file, for "BasicHttpBinding", I see in Visual Studio Can not reference service Sector is not binding with an error is found, which says:

  'http: // none Sndeshvivrn on the endpoint machine: 80 / services / myService.svc'. 'System.ServiceModel.Description.WebScriptEnablingBehavior' is for use only with WebHttpBinding or similar bindings  

How do I proceed further? I thought WCF was designed to make this thing easier. But I think I'm stuck in something very basic.

Thank you for your help!

As far as I know (but I have no experience with iPhone or WinPhone development at all ) You should be able to use the web script functionality to get your WCF service to be regular webHttpBinding and the general script WCF service:

  & lt ; System.serviceModel & gt; & Lt; Services & gt; & Lt; Service name = "myservice" & gt; & Lt; Endpoint address = "" binding = "webHTP binding" contract = "IMSI service" /> & Lt; / Services & gt; & Lt; / Services & gt; & Lt; /system.serviceModel>  

It should be enough alone - just browse to the virtual directory where the * .svc file is located and you should see your top-level resources in your browser.

Mobile devices generally do not support SOAP-style binding (like basicHttpBinding and so on) - so instead you should use webHttpBinding (Because in reality it only requires HTTP client stack on the device - and every device is definitely these days!)


Comments