Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Tip: Use XML to Send SMS Messages

By Nicholas Chase
2005-04-11


A Simple MMAP Conversation

The nice thing about MMAP, in my opinion, is that it takes advantage of the SOAP message structure. The header is used for meta-information, such as billing and session coordination, and the body is used for the message itself.

Consider, for example, the simplest possible situation: An application sends a message to a particular phone. This is considered an immediate mode situation, and might look something like this:

Listing 2. MMAP transaction
<?xml version="1.0" encoding="UTF-8"?>

<SOAP:Envelope
xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope">
<SOAP:Header>

<MMAP:MMAPHeader SOAP:mustUnderstand="1"
xmlns:MMAP="http://www.smsforum.net/schemas/mmap/v1.0"
xsi:schemaLocation="http://www.smsforum.net/schemas/mmap/v1.0
http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd">

<MMAP:ApplicationContext bodyType="Request"
sourceOperationReference="1138"/>

</MMAP:MMAPHeader>

</SOAP:Header>
<SOAP:Body>

<SMAP:SubmitRequest
xmlns:SMAP="http://www.smsforum.net/schemas/smap/v1.0"
xsi:schemaLocation="http://www.smsforum.net/schemas/smap/v1.0
http://www.smsforum.net/schemas/smap/v1.0/smap.xsd">
<SMAP:ShortMessage>
<SMAP:Header>
<SMAP:Destination>
<SMAP:Number>5555309</SMAP:Number>
</SMAP:Destination>
</SMAP:Header>
<SMAP:Body>
<SMAP:Text>Jenny, I've got your number.</SMAP:Text>
</SMAP:Body>
</SMAP:ShortMessage>
</SMAP:SubmitRequest>

</SOAP:Body>
</SOAP:Envelope>
The SOAP:Header contains the MMAPHeader, which contains information about the request itself. The ApplicationContext specifies the type of message as a Request, SuccessResponse, or ErrorResponse. It also provides a sourceOperationReference, an identifier that gets included in the response, so the requester can recognize it. Because of the SOAP:mustUnderstand attribute, if the receiver doesn't understand the MMAPHeader, it must reject the message to avoid processing it incorrectly.

The SOAP:Body contains the actual SMAP message.

Listing 3. SMAP message
<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope">
<SOAP:Header>

<MMAP:MMAPHeader SOAP:mustUnderstand="1"
xmlns:MMAP="http://www.smsforum.net/schemas/mmap/v1.0"
xsi:schemaLocation="http://www.smsforum.net/schemas/mmap/v1.0
http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd">

<MMAP:ApplicationContext bodyType="Request"
sourceOperationReference="1138"/>
<MMAP:ServiceContext serviceName="wallart">
<MMAP:AccessControl>
<MMAP:ApplicationIdentity>BRoom</MMAP:ApplicationIdentity>
<MMAP:Authentication>
<MMAP:Password>titogi</MMAP:Password>
</MMAP:Authentication>
</MMAP:AccessControl>
</MMAP:ServiceContext>

</MMAP:MMAPHeader>

</SOAP:Header>
<SOAP:Body>
...
At present, you can use plain text or MD5-encoded passwords, but the SMS Forum plans to extend this capability to include stronger security, such as certificates and tokens.

You can also use the ServiceContext to specify billing information. For example:

Listing 4. Using the ServiceContext to specify billing information
...

<MMAP:ServiceContext serviceName="wallart">
<MMAP:AccessControl>
<MMAP:ApplicationIdentity>BRoom</MMAP:ApplicationIdentity>
<MMAP:Authentication>
<MMAP:Password>titogi</MMAP:Password>
</MMAP:Authentication>

<MMAP:Billing identity="229ss">
<MMAP:Cost type="debit">
<MMAP:CostAmount amount=".3" units="dollar"/>
</MMAP:Cost>
<MMAP:ApplyTo>
<MMAP:Name>Tommy Heath</MMAP:Name>
<MMAP:Account>92988322</MMAP:Account>
</MMAP:ApplyTo>
<MMAP:Description>Per Message Plan</MMAP:Description>
</MMAP:Billing>

</MMAP:AccessControl>
</MMAP:ServiceContext>
...
The specification also allows you to add arbitrary HTML code to the Billing element, as long as it's well-formed.

Tutorial Pages:
» Reap the benefits of MMAP and SMAP
» What is SMS?
» SMAP messages
» A Simple MMAP Conversation
» Message Responses
» Other Options
» Resources


First published by IBM developerWorks


 | Bookmark
Related Tutorials:
» Starting with XML
» Performing Client-Side XSL Transformations
» Create a Google Sitemap for your Web Site
» XML and Scripting Languages
» Parsing Comma-Separated Values
» XML Security Suite: Increasing the Security of E-Business