SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sending soap requests

    hello everybody,
    I have written a code to send soap requests using javascript.It
    works perfectly fine in Internet explorer though it
    does give a security warning.But when it comes to
    netscape and firefox it doesnt work. I will paste the
    code below.
    In the following code it does not go beyond the
    smsRequest.open("POST",
    "http://sms.mxtelecom.com/soap/servlet/rpcrouter",false);
    statement.Hope you would have a look at it and give
    your valuable suggestions.

    Code:
    <script language="javascript">
    function sendSMS()
    {
    alert("hello")
    
    var smsRequest=createAjaxObj()
    alert("hello1")
    smsRequest.open("POST",
    "http://sms.mxtelecom.com/soap/servlet/rpcrouter",false);
    alert("hello2")
    smsRequest.onreadystatechange=function()
    {
    if ((smsRequest.readyState==4) &&
    (smsRequest.status==200))
    {
    alert(smsRequest.responseText)
    }
    }
    
    smsRequest.setRequestHeader("Content-Type",
    "text/xml")
    smsRequest.setRequestHeader("SOAPMethodName",
    "sendSMSMessage")
    var strEnvelope
    var
    number=document.getElementById("hidNumber").value
    var
    message=document.getElementById("txtMessage").value
    alert(number)
    alert(message)
    strEnvelope = "<?xml version='1.0'function sendSMS()
    {
    alert("hello")
    
    var smsRequest=createAjaxObj()
    alert("hello1")
    smsRequest.open("POST", "http://sms.mxtelecom.com/soap/servlet/rpcrouter",false);
    alert("hello2")
    smsRequest.onreadystatechange=function()
    {
    if ((smsRequest.readyState==4) && (smsRequest.status==200))
    {
    alert(smsRequest.responseText)
    }
    }
    
    smsRequest.setRequestHeader("Content-Type", "text/xml")
    smsRequest.setRequestHeader("SOAPMethodName", "sendSMSMessage")
    var strEnvelope
    var number=document.getElementById("hidNumber").value
    var message=document.getElementById("txtMessage").value
    alert(number)
    alert(message)
    strEnvelope = "<?xml version='1.0' encoding='UTF-8'?>"
    strEnvelope = strEnvelope + "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
    strEnvelope = strEnvelope + "<SOAP-ENV:Body>"
    strEnvelope = strEnvelope + "<ns1:sendSMSMessage xmlns:ns1='urn:SOAPSend' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>"
    strEnvelope = strEnvelope + "<user xsi:type='xsd:string'>xxxxxx</user>"
    strEnvelope = strEnvelope + "<pass xsi:type='xsd:string'>xxxxxx</pass>"
    strEnvelope = strEnvelope + "<to xsi:type='xsd:string'>" + number + "</to>"
    strEnvelope = strEnvelope + "<from xsi:type='xsd:string'>Inpora</from>"
    strEnvelope = strEnvelope + "<note xsi:type='xsd:string'>testing</note>"
    strEnvelope = strEnvelope + "<subaccount xsi:type='xsd:string'></subaccount>"
    strEnvelope = strEnvelope + "<report xsi:type='xsd:int'>1</report>"
    strEnvelope = strEnvelope + "<text xsi:type='xsd:string'>" + message + "</text>"
    strEnvelope = strEnvelope + "<flash xsi:type='xsd:boolean'>false</flash>"
    strEnvelope = strEnvelope + "<split xsi:type='xsd:int'>0</split>"
    strEnvelope = strEnvelope + "</ns1:sendSMSMessage>"
    strEnvelope = strEnvelope + "</SOAP-ENV:Body>"
    strEnvelope = strEnvelope + "</SOAP-ENV:Envelope>"
    alert(strEnvelope)
    smsRequest.send(strEnvelope)
    }
    function createAjaxObj()
    {
    var httprequest=false
    if (window.XMLHttpRequest)
    { // if Mozilla, Safari etc
    httprequest=new XMLHttpRequest()
    if (httprequest.overrideMimeType)
    httprequest.overrideMimeType('text/xml')
    alert("in here")
    }
    else
    if (window.ActiveXObject)
    { // if IE
    try {
    httprequest=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
    try{
    httprequest=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){}
    }
    }
    return httprequest
    }
    </script>

    Thanks in advance.
    Last edited by stymiee; Oct 5, 2006 at 05:22. Reason: Please use code tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •