How to create a custom XML file for ASP .NET implementations Print E-mail
Learn how to perform changes in the XML export script for ASP .NET and other applications

 

As explained in the tutorial "How to perform custom actions on incoming or outgoing SMS messages" the XML transformation script is an action activated by uncommenting the following lines from Event Handler.

#Save messages in XML format
#if [ "$1" = "RECEIVED" ]; then
#/etc/sms/scripts/sms2xml $1 $2 $3
#fi

To activate de-activate the module you have always to remember to remove/add the # sharp character.

This code represent the call on action "RECEIVED" to the sms2xml script.
The code inside the script is reported below:

#run this script only when a message was received.
if [ "$1" != "RECEIVED" ]; then exit; fi;
#Extract data from the SMS file
FROM=`/etc/procmail/formail -zx From: < $2`
TEXT=`/etc/procmail/formail -I "" <$2 | sed -e"1d"`
#Save as XML
#for some reason the mktemp-command creates two instances of the file if
#I add the .xml-extension to the FILENAME-variable.

FILENAME=`mktemp /mnt/flash/root/xml/smsXXXXXX`
BACKENDSWF="/mnt/flash/root/xml/sms.xml"
echo "" >$FILENAME.xml
echo "" >>$FILENAME.xml
echo "" >>$FILENAME.xml
echo " $FROM" >>$FILENAME.xml
echo " $TEXT" >>$FILENAME.xml
echo "" >>$FILENAME.xml
#Delete the original file without the .xml-extension
rm $FILENAME

As you can see this script perform an "export" of data from the original SMS format file and save it in a simple XML document.
In some cases you need to change the XML format to accomplish to rules of other software and for an easier integration in software environments.

XML custom script for ASP .NET integration

In the example we are going to create a simple web page that takes data from the XML file sms.xml and show it in a DataList element. We used Microsoft™ Visual Web Developer a really interesting tool that provide a simple way for ASP .NET development. You are free to download it and use it to try the example in the ZIP archive containing the source example.

The VWD environment provide a really good support to XML but as many other program it take informations from node attributes instead of content of nodes.
To override to this issue we provide you a simple script that exports informations in the correct XML format:

	Run this script only when a message was received.
if [ "$1" != "RECEIVED" ]; then exit; fi;
#Extract data from the SMS file
FROM=`/etc/procmail/formail -zx From: < $2`
TEXT=`/etc/procmail/formail -I "" <$2 | sed -e"1d"`
#Save as XML
#for some reason the mktemp-command creates two instances of the file if I
#add the .xml-extension to the FILENAME-variable.
FILENAME=`mktemp /mnt/flash/root/xml/smsXXXXXX`
BACKENDSWF="/mnt/flash/root/xml/sms.xml"
echo "" >$FILENAME.xml
echo "" >>$FILENAME.xml
echo " " >>$FILENAME.xml
echo "" >>$FILENAME.xml
#Delete the original file without the .xml-extension
rm $FILENAME

As you can see all informations are now assigned to the realtive attribute in the tag
so that you can simply assign to the file a datasource inside your ASP .NET project.
#
#Enable this to activate custom events
#
if [ "$1" = "RECEIVED" ]; then
/mnt/flash/root/source/custom/custom_rx "$2"
fi
#
As you can see, in this if clause the RECEIVED event is selected. The events you can select are: SENT, RECEIVED, FAILED or REPORT

The SMS FoxBox Software is developed by KDEV (http://www.kdev.it), a Davide Cantaluppi company on Acme Systems FOX GM Hardware

 
< Prev   Next >

FoxBox dedicated website

A new website dedicated to
SMS /MMS foxbox is online!
foxbox website

SMPP server interface

You are searching SMS speed?
KDEV SMS
http://www.smskdev.it



SMS gateway FoxBOx
buy foxbox
buy on FoxBox eShop



For further info contact us by mail This e-mail address is being protected from spam bots, you need JavaScript enabled to view it providing us the FoxBox model you need and your company details.


2009 KDEV di Davide Cantaluppi, P.IVA 02984320131
KDEV SMS è un servizio di KDEV System Development    FoxBox SMS-MMS Hardware Gateway - FoxBox appliance
SMS KDEV sms inbound SMS KDEV ricevi ed elabora tuoi SMS e invia SMS con altissime prestazioni

spacer.png, 0 kB
spacer.png, 0 kB