Skip to main content

If you don't have an IBM ID and password, register here.

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

Tip: Use XML to send SMS messages

Reap the benefits of MMAP and SMAP

Nicholas Chase (nicholas@nicholaschase.com), President, Chase and Chase, Inc.
Photo of Nicholas Chase
Nicholas Chase, a Studio B author, has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. Nick has been a high school physics teacher, a low-level radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, and an Oracle instructor. More recently, he was the Chief Technology Officer of an interactive communications firm in Clearwater, Florida, USA, and is the author of several books on Web development, including XML Primer Plus (Sams). He's currently trying to buy a farm so he and his wife can raise alpacas and chickens. He loves to hear from readers and can be reached at: nicholas@nicholaschase.com.

Summary:  Many developers tend to think of Web services as a way to easily move information from one place to another, but it's also important to understand how integral a Web service can be to the overall application. This tip gives some examples of using XML for Short Message Service (SMS) messages. If you're familiar with SMS, you'll find out how adding this tool to your toolbox can help you; if you're not an SMS developer, you'll see a real-life example of how Web services are integrated into an application.

View more content in this series

Date:  07 Jun 2004
Level:  Introductory

Comments:  

Most of the time, when people talk about Web services, they think of two different scenarios: performing a remote procedure call, or moving data from one place to another. In this tip, I show you a situation in which the message is the medium: SOAP messages that carry on an SMS transaction. This situation truly takes advantage of the SOAP message structure. The header can be used for purposes such as billing or authentication, and the body passes the actual messages.

I start by looking at SMS itself.

What is SMS?

Short Message Service (SMS) is the term used for short (typically less than 160 characters) messages that are sent between mobile phones -- instant messaging for the mobile set, if you will. It's hugely popular in parts of Europe and Japan, and is slowly gaining popularity in the United States. Typically, it works like this:

  • You send a Short Message from your phone to your friend's phone. The message goes to a Message Center.
  • If your friend is available -- meaning, her phone is turned on, and she's in the service area -- the Message Center sends it to her phone.
  • If she's not available, the Message Center holds onto the message.
  • When your friend becomes available, her phone requests the messages, which are then delivered.

In this way, SMS is more like e-mail than paging or cell phones, even though phones are usually where they come into play.

For some time now, these transactions have been carried out using HTTP, but each vendor has created its own implementation, leading to interoperability problems. To solve this problem, the SMS Forum has developed two specifications:

  • Short Message Application Part (SMAP) is an XML format for the messages themselves.
  • Mobile Message Access Protocol (MMAP) is a SOAP-based protocol for sending those messages.

In this tip, I look at how SMAP and MMAP work.


SMAP messages

The heart of an MMAP transaction is the actual message to be passed, which gets expressed as an SMAP message. The SMAP protocol was developed on the theory that when compared to the binary form that SMS messages currently take, this XML-based format is more interoperable in the short-term and easier to convert to other formats later on, if necessary.

When it comes to structure, a simple SMAP text message to be passed to a phone has much in common with a SOAP message.


Listing 1. SMAP text message
<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>

The SMAP text message consists of a header, which contains meta information (such as the destination for the message), and the body, which contains the actual message.

SMAP defines several operations, from sending a message to altering or cancelling a message that has been sent but not delivered.


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.


Message responses

Once the message is received and dealt with, the receiver sends a response. If all has gone well, it sends a SuccessResponse, such as:


Listing 5. Sample SuccessResponse
<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="SuccessResponse"
                                 sourceOperationReference="1138"/>
      </MMAP:MMAPHeader>
   </SOAP:Header>
   <SOAP:Body>

      <SMAP:SubmitResponse 
          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:MessageRef>3263827</SMAP:MessageRef>

      </SMAP:SubmitResponse>

   </SOAP:Body>
</SOAP:Envelope>

In this case, the body contains a SubmitResponse with a reference number, but no indication of whether the operation succeeded or not. That information resides in the ApplicationContext element, where the bodyType is set as SuccessResponse. The sourceOperationReference refers back to the value provided with the original request, so they can be correlated.


Other options

I haven't even begun to scratch the surface of all that you can do using MMAP and SMAP to send SMS messages with XML. The MMAP protocol supports not only this type of simple immediate message, but also sessions -- and even peer-to-peer connections -- in which both parties exchange information asynchronously within a single session. Between all of the capabilities that are built into MMAP, and the fact that it is designed to prevent interoperability problems, you'll find that it allows you to build sophisticated applications based on SMS.


Resources

About the author

Photo of Nicholas Chase

Nicholas Chase, a Studio B author, has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. Nick has been a high school physics teacher, a low-level radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, and an Oracle instructor. More recently, he was the Chief Technology Officer of an interactive communications firm in Clearwater, Florida, USA, and is the author of several books on Web development, including XML Primer Plus (Sams). He's currently trying to buy a farm so he and his wife can raise alpacas and chickens. He loves to hear from readers and can be reached at: nicholas@nicholaschase.com.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in

If you don't have an IBM ID and password, register here.


Forgot your IBM ID?


Forgot your password?
Change your password


By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)


By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, SOA and web services
ArticleID=11927
ArticleTitle=Tip: Use XML to send SMS messages
publish-date=06072004
author1-email=nicholas@nicholaschase.com
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).