Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access SOAP/ XML data w/JavaScript

Status
Not open for further replies.

tgither

Programmer
Jul 17, 2001
2
US
I cannot seem to access the individual elements of the SOAP/XML message after it is returned. None of the methods associated with the XMLDOM or XMLHTTP seem to be supported or I am using the wrong methods. If someone knows where I can locate the methods for these objects I would appreciate it.

I have successfully sent and received a SOAP message using JavaScript using the following code:

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>

<script language=&quot;JavaScript&quot;>
var objXMLStyle;
var objXMLDOM;
var jsSOAPEnvelope;

objXMLDOM = new ActiveXObject(&quot;MSXML&quot;);
objXMLDOM.async = false;

function BuildSoapEnvelope()
{
// XML elements
var jsMsgType;
var jsTimeZone;
var jsDialingNumber;
var jsCampaignId;

jsMsgType = document.testXML.msgType.value;
jsTimeZone = document.testXML.TimeZone.value;
jsDilaingNumber = document.testXML.dialingNumber.value;
jsCampaignId = document.testXML.campaignId.value;

//Build the SOAP Envelope
jsSOAPEnvelope = &quot;<SOAP-ENV:Envelope &quot; +
&quot; xmlns:SOAP-ENV=' +
&quot; xmlns:SOAP-ENC=' +
&quot; <SOAP-ENV:Body>&quot; +
&quot; <m:LiveTouchCallback xmlns:m='Line4'>&quot; +
&quot; <MessageType>&quot; + jsMsgType + &quot;</MessageType>&quot; +
&quot; <TimeZone>&quot; + jsTimeZone + &quot;</TimeZone>&quot; +
&quot; <DialingNumber>&quot; + jsDialingNumber + &quot;</DialingNumber>&quot; +
&quot; <CampaignId>&quot; + jsCampaignId + &quot;</CampaignId>&quot; +
&quot; </m:LiveTouchCallback>&quot; +
&quot; </SOAP-ENV:Body>&quot; +
&quot; </SOAP-ENV:Envelope>&quot;;

return jsSOAPEnvelope;
}

function SubmitForm()
{
var strReturn;
var strBody;

//Send SOAP Request
var objXMLHTTP = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
objXMLHTTP.open( &quot;POST&quot;, &quot;xmlserver.asp&quot;, false );
objXMLHTTP.setRequestHeader( &quot;Content-Type&quot;, &quot;text/xml&quot; );
objXMLHTTP.setRequestHeader( &quot;SOAPAction&quot;, &quot;#LiveTouchCallback&quot; );
BuildSoapEnvelope();
objXMLHTTP.send( jsSOAPEnvelope );

if( objXMLHTTP.status != 200 )
{
alert( &quot;UnSuccessful!&quot; );
}
else
{
//Show SOAP Response
strReturn = objXMLHTTP.responseText;
strBody = objXMLHTTP.responseXML.xml;
document.testXML.strReturn.value = strReturn;
}
}
</script>

</HEAD>
<BODY>
<FORM NAME=&quot;testXML&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;msgType&quot; value=&quot;0279&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;TimeZone&quot; value=&quot;P&quot;>
<b>SAMPLE PAGE</b>
<PRE>
PHONE NUMBER <INPUT TYPE=&quot;text&quot; NAME=&quot;dialingNumber&quot;>
CAMPAIGN ID <INPUT TYPE=&quot;text&quot; NAME=&quot;campaignId&quot;>
RETURN INFO. <TEXTAREA NAME=&quot;strReturn&quot; ROWS=&quot;20&quot; COLS=&quot;50&quot;></TEXTAREA>
</PRE>
<INPUT TYPE=&quot;button&quot; NAME=&quot;btnTest&quot; value=&quot;Test Button&quot; onClick=&quot;SubmitForm()&quot;>
</FORM>
</BODY>
</HTML>

Thanks,

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top