Skip to Content
Author's profile photo Pierre Dominique

Building Your First Windows Phone 7 Application (1/2)

This blog series will show you how to start

developing applications for Windows Phone 7. In this first blog, we will create

a REST Web Service on our SAP backend. In the second part, we’ll see how to

consume this Web Service in a Windows Phone 7 application.

Building your first Windows Phone 7 Application (1/2)

Building Your First Windows Phone 7 Application (2/2)

Windows Phone 7

Windows Phone 7 is the new mobile

platform from Microsoft. However it is not just another mobile platform, Microsoft

has learnt from their mistakes with Windows Mobile. As we’ll see in these

articles, one of the main advantages of Windows Phone 7 is the (freely

available) development platform. It is based on Silverlight and, as you might

expect from Microsoft, supported by excellent development tools.


A Simple REST Web Service

Instead of the old boring Hello

World stuff, let’s use a simple REST Web Service to retrieve some sample flight

data from our SAP backend. We’ll use the excellent generic controller developped by Uwe

Kunath to create it : RESTful webservices in ABAP using a generic controller  (RESTful webservices in ABAP using a generic controller).

First of all  use SAPLink (  ( to install the different components on your system.

Then create a new ZCL_RESOURCE_FLIGHTS class that

implements the ZIF_RESOURCE_HANDLER interface

and implement the HANDLE_GET method



  DATA: ls_param LIKE LINE OF it_params,

        ls_from TYPE BAPISFLDST,

        ls_to TYPE BAPISFLDST,

        ls_date_range TYPE BAPISFLDRA,

        lt_date_range TYPE TABLE OF BAPISFLDRA,

        lt_flight_list TYPE TABLE OF BAPISFLDAT.

  READ TABLE it_params INTO ls_param INDEX 1.

  ls_from-airportid = ls_param-value.

  READ TABLE it_params INTO ls_param INDEX 2.

  ls_to-airportid = ls_param-value.

  READ TABLE it_params INTO ls_param INDEX 3.

  ls_date_range-sign = ‘I’.

  ls_date_range-option = ‘EQ’.

  ls_date_range-low = ls_param-value.

  APPEND ls_date_range TO lt_date_range.



*     AIRLINE                =

      DESTINATION_FROM       = ls_from

      DESTINATION_TO         = ls_to

*     MAX_ROWS               =


      DATE_RANGE             = lt_date_range

*     EXTENSION_IN           =

      FLIGHT_LIST            = lt_flight_list

*     EXTENSION_OUT          =

*     RETURN                 =


  IF sy-subrc EQ 0.


      SOURCE tab = lt_flight_list

      RESULT XML ev_content

      OPTIONS xml_header = ‘WITHOUT_ENCODING’.


    ev_status_code = ZIF_RESOURCE_HANDLER~gc_status_ok.


    ev_status_code = ZIF_RESOURCE_HANDLER~gc_status_gone.



Then we’ll need to add some code to the GET_ROUTING method of the ZCL_RESTFUL_CONTROLLER class :

ls_routing-clnt = sy-mandt.

ls_routing-guid = ‘003’.

ls_routing-url_info = ‘/flights/from//to//date/‘.

ls_routing-handler_class = ‘ZCL_RESOURCE_FLIGHTS’.

APPEND ls_routing TO rt_routing_tab.

There’s a bug in the GET_CONTROLLER method so change the

following line of code :

*          SHIFT lv_url_info LEFT DELETING LEADING lv_url_part.

          REPLACE FIRST OCCURRENCE OF lv_url_part IN lv_url_info WITH SPACE.  

Activate everything and use

your browser of choice to navigate to

. You should get the list

of flights that meet the selection criteria in XML format :



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Guillaume GARCIA
      Guillaume GARCIA
      Hi Pierre,

      Android, Sybase Unwired Platform and now Windows Phone 7... looks like your mobility knowledge has no limit  🙂
      Looking forward to see what will be the next plaform you will deal with!

      Best regards,

      Author's profile photo Pierre Dominique
      Pierre Dominique
      Blog Post Author
      Hi Guillaume,

      I'm just trying to evaluate the different mobile platforms and see what they have to offer. And so far Windows Phone 7 is one of the most promising. 🙂


      Author's profile photo Simon Kemp
      Simon Kemp

      Thanks for taking the time to blog on this topic. I have also been looking at Windows Phone 7 and recognize great potential esp. if MS do some really great stuff for the enterprise with integration into Office and SharePoint.

      I was just wondering what your thoughts were when it comes to having to write REST based web services (or could you have used SOAP?). Most of the Enterprise Services that SAP delivers are SOAP based right? My understanding is that this is quite slow and cumbersome... is that your experience?

      Does the SYBASE unwired platform remove this need? In that scenario would the phone connect to the SYBASE middleware?


      Author's profile photo Pierre Dominique
      Pierre Dominique
      Blog Post Author
      Hi Simon,

      In my opinion SOAP is too verbose for mobile applications. I'm not even talking about SAP ES, these are way too complex to be consumed by a mobile application...

      A mobile platform such as SUP would completely remove this need because Sybase provides their own client API. The mobile application uses this API to communicate with the Unwired server, it does not connect to the backend. However SUP does not support Windows Phone 7 (yet).

      If you really need to develop a WP7 application today, you could use REST Web Services using the JSON format for maximum efficiency. This format is used by SUP for communications between the mobile client and the Unwired server.


      Author's profile photo Stephan Becker
      Stephan Becker

      Hi Pierre,

      the first part of your excellent blog is missing links and pictures, can you maybe provide a link to a full version of the text?



      Author's profile photo Pierre Dominique
      Pierre Dominique
      Blog Post Author

      Hi Stephan,

      I think the issue is related to the migration to the new SCN. The layout is messed up and some images are missing. I'll re-create the blog if I find the time to do it.



      Author's profile photo Stephan Becker
      Stephan Becker

      Hi Pierre, thanks for the reply.

      The example is understandable as is, the only thing really missing is the actual URL to test at the end.

      Also, a hint or two on how to debug the SAP part would be great, i.e. can I specify some input parameter for the method so that the URL retrieval works?! I tried to comment out the URL retrieval and debug/replace in the URL, but then the REGEX part doesn't work for some reason..

      Cheers, Stephan