Single web service for multiple devices (IPhone, Windows Phone, Silverlight, Windows 8)

Single web service for multiple devices (IPhone, Windows Phone, Silverlight, Windows 8)

At Devoteam Luxembourg, our goal was to develop a cross platform application.
We have developed a set of application based on a single “web services server”.

  • An IPhone, IPad, Android version with Sencha Touch
  • A Windows Phone 7 native version
  • A Silverlight version
  • A Windows 8 based on winRT version

This article will only talk about consuming web services on this 4 versions.  We add some constraints like activating HTTPS for enhancing security, taking care of enhancing speed for mobile devices, etc … What is the conclusion of the adventure ?! 🙂

Global architecture
Global architecture

Iphone, IPad and Android

we had set up JSON for the first time for IPhone and it was easy in IPhone side. But WCF was a bit more lazy …
Here is a sample of service header :

[WebInvoke(Method = "POST", UriTemplate = "SendRequest", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public string SendRequest(Stream multipartData)

we had to parse the multipartData stream and transform the JSON string with the JavaScriptSerializer…

Windows Phone

WCF setup was more easy.

public string SendRequest(string login, string password, int requestType, string startDate, string endDate, int startAM, int stopAM)

but we had to develop an “automatic certificate installer” for windows phone, based on If the phone does not have the certificate, it will be redirected on a website. We can’t use not trusted webservices without installing the certificate. Same as silverlight and windows 8 behavior, we do not have access to the ServicePointManager :

ServicePointManager.CertificatePolicy = delegate { return true; };


The silverlight consume the same web service than windows phone. Otherwise, it was mandatory to install the client certificate.

Windows 8

Due to close timeline, we have give up installing https for Windows 8. We use Http binding over the windows phone web service. It only use an other endpoint on the Windows Phone.


The sheet below describe what we can do and with predefined configurations :


For information here is the web.config :

<?xml version="1.0"?>
<binding name="IPhoneBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
<binding name="WP7Binding">
<security mode="Transport"/>
<binding name="WP7BindingNoHttps">
<behavior name="WebBehavior">
<webHttp />
<behavior name="TimeOffServiceBehaviors">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<behavior name="TimeOffApp.TimeOffServiceWP7Behavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<service behaviorConfiguration="TimeOffServiceBehaviors" name="TimeOffApp.TimeOffService">
<endpoint address="" behaviorConfiguration="WebBehavior" binding="wsHttpBinding" bindingConfiguration="IPhoneBinding"
name="IPhoneEP" contract="TimeOffApp.TimeOffService" />
<service behaviorConfiguration="TimeOffApp.TimeOffServiceWP7Behavior" name="TimeOffApp.TimeOffServiceWP7">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="WP7Binding" contract="TimeOffApp.TimeOffServiceWP7" />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="WP7BindingNoHttps" contract="TimeOffApp.TimeOffServiceWP7" />

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *