Secondary Data Source - Retrieving a string array from a web service - InfoPath Dev
in

InfoPath Dev

Secondary Data Source - Retrieving a string array from a web service

Last post 11-12-2009 08:12 AM by witzer. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-11-2009 03:43 PM

    Secondary Data Source - Retrieving a string array from a web service

    This is much nastier than I thought it would be.  After passing a paramer and calling the execute method (no problem), I am having a bunch of problems retrieving the string array.

    Here is the sec. data source (can't paste it) - anyway it ends like this:

    datafields - tns:GetRequesterResponse - GetRequesterResult - string

    Retrieving that string is giving me fits:

    Here is the code I use and it at least gets me the first element in the array that is returning 3, but how do I get the other 2 or should I just return a dataset from the web service??

    XPathNavigator xnMyForm = ds.CreateNavigator();

    XPathNodeIterator xp = xnMyForm.Select("/dfs:myFields/dfs:dataFields/tns:GetRequesterResponse/tns:GetRequesterResult", NamespaceManager);

     

    while (xp.MoveNext())

    {

    a[0] = xnMyForm.SelectSingleNode(
    "/dfs:myFields/dfs:dataFields/tns:GetRequesterResponse/tns:GetRequesterResult/tns:string",NamespaceManager).Value;

    }

    Thanks a lot for the help.  

     

  • 11-11-2009 10:28 PM In reply to

    Re: Secondary Data Source - Retrieving a string array from a web service

    check if this works 

    int i=0; 

    while (xp.MoveNext())

    {

    a[i] = xnMyForm.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetRequesterResponse/tns:GetRequesterResult["+i+"]/tns:string",NamespaceManager).Value;

    i++;

    }

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 11-11-2009 10:37 PM In reply to

    Re: Secondary Data Source - Retrieving a string array from a web service

     Why can't you post a screenshot of your data source?  I don't really understand which node is the repeating one from the way you described it.

    The correct approach here is to use xp.Current and relative XPaths, not to concatenate an index value into an absolute path.  If you could post a screenshot of your data source or describe whether tns:GetRequesterResult or tns:string is the repeating node, I can be of more help.

     

     

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-12-2009 07:16 AM In reply to

    Re: Secondary Data Source - Retrieving a string array from a web service

    Qazi - that doesn't work as it only goes through the while loop for 1 iteration.

    Jimmy - wasn't able to paste the screenshot for some reason.  I'm getting blocked from pasting into this message, but perhaps I can explain datasource better.

    I am returning a string array.  In the datasource, it is showing GetRequesterResult as a group and 'string' as the repeating.  When I hover over 'string' in the datasource it shows: string(Field) Repeating Data Type:(string).

    I hope this makes sense and really wish I could paste screenshot and as always thanks for the help.

     

     

      

    Filed under:
  • 11-12-2009 07:56 AM In reply to

    Re: Secondary Data Source - Retrieving a string array from a web service

     You can attach files to messages in this forum by clicking the Options tag when creating a message.

     Please try this code:

     XPathNodeIterator xp = xnMyForm.Select("/dfs:myFields/dfs:dataFields/tns:GetRequesterResponse/tns:GetRequesterResult/tns:string", NamespaceManager);

    while (xp.MoveNext())
    {
         a[0] = xp.Current.Value;
    }

     Of course, this will just overwrite a[0] repeatedly, so you'll need to devise a way of storing the retrieved data in a more logical manner.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-12-2009 08:12 AM In reply to

    Re: Secondary Data Source - Retrieving a string array from a web service

    Jimmy -

    You are a genius - thanks so much.  I hope to get better and better at programming this stuff and hopefully some day I can help somebody out.

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