Parse string array from web service - InfoPath Dev
in

InfoPath Dev

Parse string array from web service

Last post 12-22-2010 11:33 AM by jyehwyle. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 12-21-2010 04:18 PM

    Parse string array from web service

    I'm looking for some help with pulling data from a web service. The web service pulls user account info from Active Directory and returns a string array. The string array shows up as simply "string" under the web service data source in Infopath. When I set a field with the returned data and submit the form, only the first item in the array is actually returned. Is there a way to pull a specific item in the string array without using code? I've tried tweaking the xpath, but haven't been successful. Here's what the xpath looks like.

     xdXDocument:GetDOM("GetADUser")/dfs:myFields/dfs:dataFields/tns:GetADUserResponse/tns:GetADUserResult/tns:string

     

  • 12-22-2010 06:15 AM In reply to

    Re: Parse string array from web service

    You can use filtering to pull down one specific item. We document this for our AD web service here:

    http://www.infopathdev.com/files/folders/other_topics/entry56832.aspx

    Hope it helps!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 12-22-2010 07:59 AM In reply to

    Re: Parse string array from web service

    Thanks for the reply Ernesto.

    However I don't think filtering will work in my case since the AD web service I'm using returns a single dimension string array. The Qdabra web service seems to return key value pairs (or maybe a multi-dimensional array). I need to somehow specify the index of the string array in Infopath.

  • 12-22-2010 08:08 AM In reply to

    Re: Parse string array from web service

     xdXDocument:GetDOM("GetADUser")/dfs:myFields/dfs:dataFields/tns:GetADUserResponse/tns:GetADUserResult/tns:string[index]

    should work.  Note that index here is 1-based, not 0-based.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-22-2010 08:20 AM In reply to

    Re: Parse string array from web service

     

    Jimmy:

     xdXDocument:GetDOM("GetADUser")/dfs:myFields/dfs:dataFields/tns:GetADUserResponse/tns:GetADUserResult/tns:string[index]

    should work.  Note that index here is 1-based, not 0-based.

    That was the first thing I tried and it didn't work. I tried it again, but every time I publish the form Infopath throws the below error. If only it was that easy to specify a specific item in the array.

     "The following expression could not be parsed because of a syntax error or because it uses an undefined namespace prefix or unsupported function."

  • 12-22-2010 08:29 AM In reply to

    Re: Parse string array from web service

    Well, that should work.  Are you saying it the expression is fine without the [] part, but as soon as you add the [] part it gives that error?  Could you paste the exact expressions you're using with and without the [] part (and check the Show XPath checkbox before you do).

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-22-2010 08:33 AM In reply to

    Re: Parse string array from web service

    Yeah, the expression works without the [] part. Here's what I just tested.

    xdXDocument:GetDOM("GetADUser")/dfs:myFields/dfs:dataFields/tns:GetADUserResponse/tns:GetADUserResult/tns:string[2]

    Without the [] is what I posted in my original message. Is it possible an issue w/ Infopath Form Services? I'm publishing the form to Sharepoint.

  • 12-22-2010 08:58 AM In reply to

    Re: Parse string array from web service

    After some searching around, it looks like this is a limitation of IPFS.  It seems browser-based forms don't allow using XPath with filters (i.e. using brackets []). 

    Is the Web Service you're calling something that your organization designed, or a third-party service?  If there's any way to get the service to return the values in XML with named nodes, that might be an ideal solution to this issue.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-22-2010 11:33 AM In reply to

    Re: Parse string array from web service

    The web service is something I actually designed, but other applications from my company use it besides the one I'm making now. So I'd rather not change the web service.

    Well, perhaps I'll duplicate the method I'm using for my Infopath form and change the output format. Seems like the only option in Infopath to parse string arrays is to use custom code, and I really want to avoid that since I have a lot of rules in place.

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.