Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

web service call & other browsers

I am making a call to web service from client side(asp.net & vb). the code is working fine for IE( i used ActiveXObject for IE). i also used xmlHttpRequest for othere browsers. the problem is after getting the xmlresponse how do i load the document and assign particular node value to a label or textbox for other browsers.

xmlResponse.load(xmlHttp.responseXML);

xmlNode = xmlResponse.getElementsByTagName('xml');
borrowerNode = xmlNode[0].childNodes[1];
if(borrowerNode.hasChildNodes())
{
var i = 0;
var xmlChildNode, nodeVal='';
while(borrowerNode.childNodes[i])
{
// get node
xmlChildNode = borrowerNode.childNodes[i];
// check nodetype
if(xmlChildNode.nodeType != 3) // #text == 3
{

// get nodeValue (aka text)
nodeVal += xmlChildNode.firstChild.nodeValue + ' ';
}
i++;
}
// set control value to nodeValue
document.getElementById('lblDataUpdate').innerHTML = nodeVal;
}
Thanks!
0 Kudos
Message 1 of 14
(10,902 Views)
It's difficult to tell what's going on from the code because it's not clear what the types of the variables are, what the errors are, or where they're occurring. I'm guessing that the xmlResponse variable is a DOM document object and the xmlHttp variable is an XMLHttpRequest object. I'm also guessing that the error is either occurring when you're createing the MSXML DOM document in non-IE browsers or when you're calling the load method in IE browsers.

If that's not the case, what are these variables, what is the error that you're getting, and when/where does it happen? If that is the case, you do not need to create xmlResponse and then call load on xmlHttp.responseXML. The responseXML proprerty of XMLHttpRequest is a DOM document and can be parsed usi
ng W3C DOM node tree methods and properties. Does this help answer your question?

- Elton
Message 2 of 14
(10,901 Views)
i attached a test document. after getting the xmlHttp.ResponseXML, i am not able to display the response in netscape/mozilla. i am able to display in IE.

Thanks!
0 Kudos
Message 3 of 14
(10,901 Views)
Could you please also post the code for your sample web service? It's difficult to run the example without having a service that it can communicate with, or at the very least knowing what the GetSampleData web method is returning so I could recreate the service. Thanks.

- Elton
0 Kudos
Message 4 of 14
(10,901 Views)
I attached the web service code.
Thanks for your time. I appreciate your help.
0 Kudos
Message 5 of 14
(10,901 Views)
I'm not nearly as familiar with Mozilla's client-side support as IE's, so this may not be the best answer, but here are a few things that I found that seemed to work after playing with it for a bit.

First, you were specifying false for the third parameter of the XML HTTP request open method, which means to not call open asynchronously. As far as I can tell, if you specify that open should be called synchronously, the event handler for onreadystatechange will not be called in Mozilla. Changing this to true caused the event handler (in your case, xmlHttp_change) to start getting called in Mozilla.

The next problem that I saw is that you were trying to get elements named 'xml' with the getElementsByTagName method, but the XML that's coming back from the web service looks like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<soap:Body>
<GetSampleDataResponse xmlns="http://tempuri.org/TestWebService/Service1">
<GetSampleDataResult>&lt;table cellspacing='0' width=730px cellpadding='4' rules='all' bordercolor='#990000' border='2' style='background-color:White;border-color:#CC9966;border-width:1px;border-style:None;font-family:Times New Roman;font-size:X-Small;border-collapse:collapse;'&gt;&lt;tr style='color:white;background-color:darkblue;font-weight:bold;'&gt;&lt;TH align='left'&gt;Name1&lt;/TH&gt;&lt;TH align='left'&gt;Name2&lt;/TH&gt;&lt;TH align='left'&gt;Name3&lt;/TH&gt;&lt;/TR&gt;&lt;TR borderColor='#990000'style='color:red;font-size:X-Small '&gt;&lt;TD align='left'&gt;Test1&lt;/TD&gt;&lt;TD align='left'&gt;Test2&lt;/TD&gt;&lt;TD align='left'&gt;Test3&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
</GetSampleDataResult>
</GetSampleDataResponse>
</soap:Body>
</soap:Envelope>

There are no elements named 'xml' here. One way that you can get to the content in IE is like this:

var content = xmlResponse.selectSingleNode("soap:Envelope/soap:Body/GetSampleDataResponse/GetSampleDataResult").text;

Unfortunately, Mozilla's XMLDocument class doesn't support selectSingleNode. I couldn't find a good reference on Mozilla's XMLDocument object, so I tried using just W3C DOM methods. To determine the W3C DOM methods, I looked at the MSXML reference on MSDN and looked at the members that did not have a * next to them. The main page that I looked at was for IXMLDOMNode, which describes the API members for a DOM node. It seems like there should be a better way to do this, but here is one way I was able to get to the content in Mozilla:

var envelopeElement = xmlResponse.childNodes.item(0);
var bodyElement = envelopeElement.childNodes.item(0);
var sampleDataResponseElement = bodyElement.childNodes.item(0);
var sampleDataResultElement = sampleDataResponseElement.childNodes.item(0);
var content = sampleDataResultElement.childNodes.item(0).nodeValue;

Once you have the data in the content variable, you can update the HTML as you were before:

document.getElementById('lblDataUpdate').innerHTML = content;

I was able to get the web service call working in both IE and Mozilla with the code above, so hopefully this helps. Another option that you may want to look at is looking at each browser's support for web services instead of using XMLHTTP. For IE, see the WebService behavior. For Mozilla, see Mozilla's web services support page.

- Elton
0 Kudos
Message 6 of 14
(10,901 Views)
Thanks a lot for your detailed response. yeah, its working in mozilla.
0 Kudos
Message 7 of 14
(10,901 Views)

Hi !

 I will send an xml file to a Web Service. Can everybody Help me how can i send in with Lab View ?

Thank

0 Kudos
Message 8 of 14
(10,322 Views)
Hello Caki,
 
There are a variety of ways (protocols) you can use to communicate with a web service -- whether your're using XML or not. I would suggest taking a look a the following document on our webpage:
 
Building a Web Service-Based Application in LabVIEW 7.0
 
The LabVIEW .NET Web Service Browswer example is an excellent way to get started with an application of this nature. Alternatively, if you already have a .NET interface for your web service you could use the methods and property nodes in LabVIEW to invoke the .NET assembly. You can find more information about this here:
 
Using .NET with LabVIEW
 
Hope this helps!
Charlie S.

Visit ni.com/gettingstarted for step-by-step help in setting up your system
0 Kudos
Message 9 of 14
(10,307 Views)

Hí !

 

 Thanks, i'll Probe it.

 

 

0 Kudos
Message 10 of 14
(10,300 Views)