tags:

views:

114

answers:

1

Hi,

I am creating a RESTful service which has to create WAP pages dynamically. I am wondering if it is possible to create a generic "wml" object with members representing wap elements (for example card, option...) so the service could simply return a wap page, for example:

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"&gt;

<wml>
  <card id="card1" title="Tutorial">
    <do type="accept" label="Answer">
      <go href="#card2"/>
    </do>
    <p><select name="name">
      <option value="HTML">HTML Tutorial</option>
      <option value="XML">XML Tutorial</option>
      <option value="WAP">WAP Tutorial</option>
    </select></p>
  </card>
  <card id="card2" title="Answer">
    <p>You selected: $(name)</p>
  </card>
</wml>

I haven't tried to do this yet so I would appreciate if anyone could suggest a good way to dynamically create a content similar to the example above using REST service.

A: 

It's most certainly possible to return WAP-based representations from a RESTful web service. REST allows you to design and return whatever representations you want.

You'll need to make sure you do the proper media type processing though. Each client request will come with an HTTP Accept header, which lists the media type(s) that client is able to accept. If it accepts only WAP WML representations, the Accept header will contain something like text/vnd.wap.wml (see IANA media type, and double check this against what your actual clients send). In this case, your REST web service would generate a WML page in response, and set the Content-Type to text/vnd.wap.wml.

The actual WML page generation inside your web service is done the same way that you would create HTML pages, with whatever tools you want (eg, Java servlets, PHP, Ruby on Rails). I have friends who have written services that generate HTML pages, WML pages, or VoiceXML pages based on what kind of client is asking for them.

Jim Ferrans