Article ID: 555578 - View products that this article applies to.
This article discusses the complete know-how of SMS services and the tools used for developing web based mobile applications in ASP.NET. It also deals with the components required for SMS services available in .NET compact framework.
This article is aimed at clarifying more information on using SMS services in mobile.net applications. Developers would find it useful in understanding the basic concepts behind using this service in their applications
This article discusses about the SMS and its capabilities in detail. Also, it deals with variety of ways of using SMS enabled .net applications.
SMS – Short Messaging Service is quite a buzz word in the developing community nowadays. When it comes to .NET environment, developers are really into it finding a solution for sending and receiving SMS from their web applications. Most of the web applications have a SMS feature in-built enabling the users to send a simple text to mobile numbers for instant correspondence. For its speed, accuracy and increased productivity, SMS is one of the most successful services among the various wireless services.
SMS is capable of delivering numerous data services to wireless devices, including voice-mail alerts, fax services, ring tones, games etc. A SMS may also be a TMS (Text-Messaging service). A wireless text message is a short string of up to 256 characters that can be sent to a mobile device.
Though the text messaging service was initially used with PAGER devices that support alpha-numeric numbers, it has found a place in the mobile phones also.
Many mobile wireless carriers have made it extremely difficult for developers to get into knowledge source of SMS and its features. They use different modes of handling SMS messages for many reasons. One of the reason is that the cost involved for the very message itself. Some carriers develop API for SMS that can send or receive SMS using the TCP/IP. Some others use protocols like Simple Network Paging Protocol (SNPP), the Wireless Communication Transport Protocol (WCTP), and the Short Message Peer to Peer (SMPP). Some carriers now expose a Simple Mail Transport Protocol (SMTP), an e-mail interface to send short text messages. In this case, the e-mail address will be the device's phone number or pager identification number, along with the wireless carrier's special domain. For example, a phone with Reliance service will have an e-mail address of 3135551212@mobile.Reliance.net.
The prerequisite for using the SMS capabilities is the SMS gateway. You can have access to the SMS with mobile network(service providers), via a web interface or an API. They would supply you with a set of APIs that work with their SMS servers. Again, this involves a cost for sending messages and providing services.
Alternatively, there are a few mobile phone web sites that allow you to send/receive an SMS using their web site. You can develop a web page in ASP.NET that can be posted to that site for providing SMS services to your users. In India, www.mantraway.com, www.mysmsaddress.com,
www.smscountry.com, www.smsjunction.com are few websites that offer the SMS and related services for corporate and high volume SMSC links using SMPP (Short Message Peer to Peer) communication protocol.
A SMSC (Short Message Service Center) regulates the message transfer to and from the mobile phones in GSM-networks. This includes not only short text messages but also fax, voice- or e-mails. It delivers the messages, temporarily stores them in case the respective recipient is currently not available and takes care of charging. There is at least one SMSC per network.
The third option is considering a subscription to a SMS webservice using which you can send or receive SMS in your application. Go to www.webservicex.com , you can find a number of webservices that deals with SMS services. One of the most widely used service is available in http://www.salcentral.com/help/msgservice.com
SMS services can be provided with the use of GPRS (General Packet Radio Service) that offers Internet email services. This would be the simplest form of providing SMS services in your applications.
GPRS facilitates continuous wireless connection to data networks and access to your favorite information and entertainment services. It allows mobile phones to be used for sending and receiving data over an Internet Protocol (IP)-based network. Besides SMS, other service protocols like WAP, MMS, SMS, Java and the PC dial-up (for example, Internet and e-mail) are also supported by GPRS.
Unlike SMS gateway services, Internet email services stores the messages using mailbox services. The emails are actually stored and the user gets a notification on their mobile phone and can then retrieve the full email by dialing in to collect it, forward it, and so on. Gateway services offers a wireless email platform wherein it simply translates the message from SMTP(the Internet email protocol) into SMS and sends to the SMS Center.
Most of the times, on receiving a new email, Internet email users do not get notifications on their mobile phones. They need to dial in periodically to check their mailbox. However, we can link the Internet email system with an alert mechanism such as SMS or GPRS, and users can be notified when a new email is received.
The Mobile Internet Toolkit (MMIT) from Microsoft also called as ASP.NET mobile controls is an extension to the .NET Framework and ASP.NET that allows developers to write mobile Web applications targeting multiple devices such as cell phones and PDAs. The MMIT frees the developer to concentrate on the application logic and leave the UI rendering to the runtime. To install MMIT, you need to have the Microsoft .NET Framework version 1.0 or later. Because MMIT is an extension of ASP.NET you must also have IIS running.
Mobile applications are of two types: Web-based and device based.
Web based mobile applications run on the server, typically the Web server, and is accessed by mobile devices through the Internet and SMS services provided by Internet Email messages.
Device specific mobile applications are standalone applications running on the devices itself, with or without Internet access. For this type of application, Microsoft provides a scaled-down version of the .NET Framework—the .NET Compact Framework (.NET CF).
.NET Compact Framework applications target devices like Pocket PCs, Smart Phones, PDAs. It is based on Windows CE. The core set of functions for smart-device systems and applications are available in COREDLL.DLL. It also has the following dlls:
AYGShell.dll – Pocket PC shell functions
CommCtrl.dll – Common control lib
WinSock.dll – Windows Sockets
Phone.dll – High level phone control
SMS.dll – SMS messaging API
Using the P/Invoke support available in .NET CF for calling Win32 API functions in unmanaged dlls, we can send SMS from a C# or VB.NET CF application.
SmsOpen function opens the SMS messaging component.
HRESULT SmsOpen (
const LPCTSTR ptsMessageProtocol,
const DWORD dwMessageModes,
SMS_HANDLE* const psmshHandle,
HANDLE* const phMessageAvailableEvent);
ptsMessageProtocol is a string denoting that SMS protocol to use. dwMessageModes specifies whether we want to be in send or receive mode.
psmshHandle is a pointer to the handle of the SMS session and is valid only if the function returns properly. phMessageAvailableEvent is the handle to a Win32 event handle that can be used to determine when the next message is available to be read.
Using the DllImport attribute in the System.Runtime.InteropServices namespace, we can declare the functions in our code.
SmsSendMessage function sends the message to a mobile number.
HRESULT SmsSendMessage (
const SMS_HANDLE smshHandle,
const SMS_ADDRESS * const psmsaSMSCAddress,
const SMS_ADDRESS * const psmsaDestinationAddress,
const SYSTEMTIME * const pstValidityPeriod,
const BYTE * const pbData,
const DWORD dwDataSize,
const BYTE * const pbProviderSpecificData,
const DWORD dwProviderSpecificDataSize,
const SMS_DATA_ENCODING smsdeDataEncoding,
const DWORD dwOptions,
SMS_MESSAGE_ID * psmsmidMessageID);
smshHandle is the handle returned in psmshHandle by SmsOpen. psmsaSMSCAddress is an optional parameter specifying which SMS Message Center is to be used. If NULL is used, the user's default SMSMC will be used.
psmsaDestinationAddress is where the message is to be delivered. pstValidityPeriod breaks from the standard SYSTEMTIME structure in that it is the amount of time past sending of an SMS during which the message still is considered valid.
pbData is the byte representation of the message's data portion. This can be NULL.
dwDataSize is the size in bytes of the message's data portion. pbProviderSpecificData is additional information required by some providers to allow an SMS to transmit correctly. dwProviderSpecificDataSize is the size in bytes of the previously mentioned field.
smsdeDataEncoding is an option found within the SMS_DATA_ENCODING enumeration detailed above. dwOptions are (currently) two flags that will fail an SMS after one attempt or will allow it to be redelivered until the router gives up. psmsmidMessageID will be non-null if this function returns successfully.
In our managed code, we use it as
SmsClose function closes an SMS message service request.
HRESULT SmsClose (
const SMS_HANDLE oCommandBarPopup);
In this sample, I use an already existing webservice from www.webservicex.com. It provides Web Service Definition Language (WSDL) link for sending SMS. You must add a web reference to the following webservice in your CF.NET application:
Developing applications that provide SMS services is not a simple task. You must install the appropriate tools and components in your system to develop mobile applications in .NET environment.
If you are developing a mobile based SMS service, you need to rely on SMS gateway software components or you can make use of existing webservice which uses them. There is another finest way of providing SMS capability to your application that uses the AT commands which comes as a variety of sets for different mobile devices. This is not discussed in this article.
If you are developing a device based SMS service application, you can go for .NET compact framework that is being shipped with Visual Studio .NET 2003/2005 or you can download it from the internet. Here again, most of the dll components you need for developing SMS services are available with Windows CE 4.2/5.0 SDK toolkit, not available with .NET CF.
Hope you enjoyed reading this article. If you have any comments or suggestions, please feel free to contact me at email@example.com.
Article ID: 555578 - Last Review: March 22, 2006 - Revision: 1.0
COMMUNITY SOLUTIONS CONTENT DISCLAIMER
MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.