DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

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

Benjamin Laffont user avatar by
Benjamin Laffont
·
Jan. 20, 12 · · Interview
Like (0)
Save
Tweet
3.60K Views

Join the DZone community and get the full member experience.

Join For Free
online version is at : http://www.alphablog.org/2012/01/20/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

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 :
[operationcontract]
[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.
[operationcontract]
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 http://wp7certinstaller.codeplex.com . 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; };

silverlight

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.

summary

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



for information here is the web.config :
<?xml version="1.0"?>
  <configuration>
    <system.web>
<system.servicemodel>
<bindings>
<wshttpbinding>
<binding name="iphonebinding">
<security mode="transport">
<transport clientcredentialtype="none" />
</security>
</binding>
</wshttpbinding>

<basichttpbinding>
<binding name="wp7binding">
<security mode="transport"/>
</binding>
<binding name="wp7bindingnohttps">
</binding>
</basichttpbinding>
</bindings>

<behaviors>
<endpointbehaviors>
<behavior name="webbehavior">
<webhttp />
</behavior>
</endpointbehaviors>

<servicebehaviors>
<behavior name="timeoffservicebehaviors">
<servicemetadata httpsgetenabled="true" />
<servicedebug includeexceptiondetailinfaults="true" />
</behavior>

<behavior name="timeoffapp.timeoffservicewp7behavior">
<servicemetadata httpsgetenabled="true" />
<servicedebug includeexceptiondetailinfaults="true" />
</behavior>
</servicebehaviors>
</behaviors>

<servicehostingenvironment aspnetcompatibilityenabled="true" />

<services>
<service behaviorconfiguration="timeoffservicebehaviors" name="timeoffapp.timeoffservice">
<endpoint address="" behaviorconfiguration="webbehavior" binding="wshttpbinding" bindingconfiguration="iphonebinding"
name="iphoneep" contract="timeoffapp.timeoffservice" />
</service>
<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" />
</service>
</services>
</system.servicemodel>
</system.web>
</configuration>
Web Service Windows Phone

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Component Testing of Frontends: Karate Netty Project
  • What Is High Cardinality?
  • Event-Driven Hello World Program
  • Artificial Intelligence (AI) And Its Assistance in Medical Diagnosis

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo