Samples - ASP-VB

Web Service

Using the 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 Web Service.


    Dim oSOAP       ' The SOAP Toolkit object
    Set oSOAP = Server.CreateObject("MSSOAP.SoapClient30")
    oSOAP.ClientProperty("ServerHTTPRequest") = True
    oSOAP.mssoapinit("https://www.textapp.net/webservice/service.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://www.textapp.net/webservice/service.asmx?wsdl")
    

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


    result = oSOAP.SendSMS(false, "myExternalLogin", "myPassword", "clientBillingReference", _
                           "clientMessageReference", "+447923456789", "+447923456789", _
                           "hello world", 72, 2, 4,  "",  "");
    Response.Write(result)
    

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

HTTPS Service

Connecting to the HTTPS Service involves making a HTTPS 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 HTTPS GET method:


    Dim xmlhttp
    Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")

    xmlhttp.Open "GET","https://www.textapp.net/webservice/httpservice.aspx _
                        ?method=sendsms&returncsvstring=false _
                        &externallogin=mylogin&password=mypassword _
                        &clientbillingreference=myclientbillingreference _
                        &clientmessagereference=myclientmessagereference _
                        &originator=mynumber&destinations=%2b447912345678 _
                        &body=hello%20world&validity=72&charactersetid=2 _
                        &replymethodid=4&replydata=&statusnotificationurl="
                        
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send()

    Response.Write xmlhttp.responseText
    

You can achieve the same result by using the HTTPS POST method:


    Dim xmlhttp
    Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")

    xmlhttp.Open "POST","https://www.textapp.net/webservice/httpservice.aspx"
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send("method=sendsms&returncsvstring=false _
                  &externallogin=mylogin&password=mypassword _
                  &clientbillingreference=myclientbillingreference _
                  &clientmessagereference=myclientmessagereference _
                  &originator=mynumber&destinations=%2b447912345678 _
                  &body=hello%20world&validity=72&charactersetid=2 _
                  &replymethodid=4&replydata=&statusnotificationurl=")

    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:


    encodedValue = Server.URLEncode("hello world")