Samples - ASP-VB

Web Service

Using the TextAnywhere Web Service can be achieved by installing the Microsoft SOAP Toolkit on the computer that will be executing your ASP pages. Once installed, you can use the TextAnywhere Web Service.

Dim oSOAP ' The SOAP Toolkit object Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.mssoapinit("https://ws.textanywhere.net/ta_SMS.asmx?wsdl")

If there is a proxy server between your code and the internet you may need to specify the proxy details.

Dim oSOAP ' The SOAP Toolkit object Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.ConnectorProperty("ProxyServer") = "proxyserver:8080" oSOAP.ConnectorProperty("ProxyUser") = "username" oSOAP.ConnectorProperty("ProxyPassword") = "password" oSOAP.mssoapinit("https://ws.textanywhere.net/ta_SMS.asmx?wsdl")

Once you have an initialized SoapClient object, you are free to call methods. For example, to call the SendSMSEx method:

result = oSOAP.SendSMSEx("my_id", "my_pass", "my_ref", "billing_ref", _ 2, "+447912345678", 0, "+447923456789", _ "Hello World", 0, 0, "") Response.Write(result)

This shows how to call the SendSMSEx method providing the parameters it requires. You may call any of the other Web Service methods in a similar manner.

TextPremium Web Service

Similarly to using the standard TextAnywhere Web Service, you may use the Microsoft SOAP Toolkit to connect to the TextAnywhere TextPremium Web Service. You will need to install it on the computer which is executing your ASP pages. Once installed you can connect to and use the TextPremium Web Service.

Dim oSOAP ' The SOAP Toolkit object Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.mssoapinit("https://ws.textanywhere.net/ws_textpremium/TA_WS_RB.asmx?wsdl")

Please note the different URL pass to the mssoapinit method of the oSOAP object.

If there is a proxy server between your code and the internet you may need to specify the proxy details.

Dim oSOAP ' The SOAP Toolkit object Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30") oSOAP.ClientProperty("ServerHTTPRequest") = True oSOAP.ConnectorProperty("ProxyServer") = "proxyserver:8080" oSOAP.ConnectorProperty("ProxyUser") = "username" oSOAP.ConnectorProperty("ProxyPassword") = "password" oSOAP.mssoapinit("https://ws.textanywhere.net/ws_textpremium/TA_WS_RB.asmx?wsdl ")

Once you have an initialized SoapClient object, you are free to call methods. For example, to call the ReadTextMT method to retrieve incoming messages:

result = oSOAP.ReadTextMT("my_id", "my_pass", "80000_keyword") Response.Write(result)

To send responses to incoming messages you will use the SendMTResponse method:

result = oSOAP.SendMTResponse("my_id", "my_pass", "my_ref", _ "RBID", "Thanks! you won") Response.Write(result)

You may call any of the other TextPremium Web Service methods in a similar manner.

HTTP(S) Service

Connecting to the TextAnywhere HTTP(S) Service involves making a HTTP(S) request from your ASP code. This can be done fairly simply using Microsoft’s ServerXMLHTTP object. It should be available on most servers running Windows 2000 or newer.

Proxy settings must be specified using the proxycfg.exe command line utility. This utility has an option to import settings from Internet Explorer if you wish.

In order to send an SMS using the HTTP(S) GET method:

Dim xmlhttp Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP") xmlhttp.Open "GET","https://ws.textanywhere.net/HTTPRX/SendSMSEx.aspx?Client_ID=my_id&Client_Pass=my_pass&Client_Ref=my_ref&Billing_Ref=billing_ref&Connection=2&Originator=%2b447912345678&OType=0&DestinationEx=%2b447923456789&Body=hello%20world&SMS_Type=0&Reply_Type=0" xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlhttp.send() Response.Write xmlhttp.responseText

You can achieve the same result by using the HTTP(S) POST method:

Dim xmlhttp Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP") xmlhttp.Open "POST","https://ws.textanywhere.net/HTTPRX/SendSMSEx.aspx" xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlhttp.send("Client_ID=my_id&Client_Pass=my_pass&Client_Ref=my_ref&Billing_Ref=billing_ref&Connection=2&Originator=%2b447912345678&OType=0&DestinationEx=%2b447923456789&Body=hello%20world&SMS_Type=0&Reply_Type=0") Response.Write xmlhttp.responseText

The parameter values must be URL encoded as in the examples “hello world” becomes “hello%20world”. You can URL encode values:

encoded_value = Server.URLEncode("hello world")

Footer Bottom