Expand my Community achievements bar.

Using javascript to access XML from SOAP Webservice returned to variable

Avatar

Level 1

Guys

Is there a javascript method of accessing the SOAP XML data in a javascript variable populated from a web service?

For example, using the following JavaScript I can access the SOAP XML data (see example below) returned to a result variable.


result = service.ZDataService(); //Calls web service and returns SOAP envelope to result

for (var i in result)
{
     form1.DropDownList1.addItem(i) // Populates drop down with Contents and ReturnContents values

     for (var j in result[i])
          {
               form1.DropDownList1.addItem(j) // Adds Item, Item values to drop down
               for (var k in result[j])
                    {
                         form1.DropDownList1.addItem(k) // I thought that this would add Name/Date to the drop down but it doesn't!  How can I get further into the XML?
                    }
          }
}

Below is the XML returned in the SOAP body.

<Contents>
     <Item>
          <Name>String</Name>
          <Date>String</Date>
     </Item>
</Contents>

<ReturnContents>

     <Item>
          <Name>String</Name>
          <Date>String</Date>
     <Item>

</ReturnContents>

I recognise that one method to deal with this would be to parse the XML and use XFA to access it.  I am working on this in another thread.

However, are there any javascript experts out there who can advise the correct javascript to access the contents of the XML in a SOAP envelope when it is returned to a javascript variable.

If I can access the contents of the XML via javascript, I can then populate the values of form fields and drop downs etc etc.

Any ideas?

Many thanks

Rox

2 Replies

Avatar

Former Community Member

Its been a while since I have done this but I think you simply path your way  to the node that you want....something like this:

result.Contents.Item.Name

Do you have access to the Acrobat Javascripting reference. The SOAP commands are well documented there as well as a numbe of samples are provided.

Paul

Avatar

Level 1

Hi Paul

I have access to all the documents (JavaScript via Mozilla, Adobe JavaScript API, XFA API etc etc) but none are specific enough to cater for this issue.  I will work this out before too long but it would be very useful if someone who had done this already could shortcut my journey!

Thanks

Roxy