On this page C# developers can learn how to use the HTTP protocol for SMS messaging with the Ozeki Message Server.
HTTP is the primary transport mechanism for communicating with resources over the World Wide Web. Developers often use this protocol because of its simplicity and popularity, and also because it enables them to bypass firewalls and proxies. HTTP is a request/response protocol between clients and servers. Using the Ozeki Message Server you can easily send SMS messages with a simple HTTP request. You can also receive SMS messages using the Ozeki SMS Server by implementing a very simple web server.
If you would only like to send messages using the HTTP protocol, you do not need to configure the Ozeki Message Server. Therefore, you may as well skip this paragraph. However, if you also want to receive SMS Messages, you need to configure the OZEKI Message Server to enable it to act as an HTTP Client. For this, you need to install and configure a HTTP Client plugin. To find out how to install and configure the HTTP Client plugin, check out the following page:HTTP Client Plugin. In the appropriate tab, you need to set a base URL where the messages will be sent.
(Example: http://127.0.0.1:9400/getresponse.php?sender=$SENDER& receiver=$RECEIVER&msg=$MSG)
By configuring the HTTP Client plugin, you instruct the Ozeki Message Server to forward all incoming SMS messages to the base URL with the specified parameters. As a result, a web server listening on the base URL can easily process the messages.
Sending SMS using HTTP request/response in C#
To send SMS using the HTTP protocol, you only need to create a web request to the Ozeki Message Server. You can also receive the results of your request with a web response. In C# you can achieve this with a few lines of code:
You have to create a special HTTP request to the OZEKI Message Server, which listens on the 9333 port by default. This request starts with the hostname and the name of the port the Ozeki Server listens on (127.0.0.1:9333 in our example). You need to request a virtual page called ozeki and send it the parameters, depending on the action you intend to perform. For sending SMS messages you have to use:
See more at : http://www.ozeki.hu/index.phtml?ow_page_number=654page_name=sms_HTTP_Server_SMS
After creating the request and calling the GetResponse() method on the request, the SMS Message will be sent, and you can optionally read the response. The response should look like this:
Receiving SMS using HTTP request/response in C#
To receive SMS messages using HTTP, you need to start a simple web server
which is very easy in C# on Windows XP, SP2 or Server 2003. First, you need to
create a new HttpListener object using the constructor of the HttpListener class .
Use the Prefixes property to gain access to a specific Uniform Resource Identifier (URI),
which will be the base URL.
Once your web server receives a HTTP request,
the callback (ListenerCallback()) function will be called. This method will end
the asynchronous operation with the EndGetContext() and immediately start a new context
for the next request. The ProcessRequest() method can now process the incoming request.
Each parameter of the request can be accessed by its name. For example, the message data
will be in context.Request.QueryString["msg"].
In the request the sender�s number is optional, but the recipient�s number and the message text are mandatory.