Return complex type (rep. table) from WebService - InfoPath Dev
in

InfoPath Dev

Return complex type (rep. table) from WebService

Last post 01-03-2007 03:17 AM by fahlen. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-03-2007 01:58 AM

    • fahlen
    • Not Ranked
    • Joined on 12-29-2006
    • Posts 7

    Return complex type (rep. table) from WebService

    Hi,

    I was hoping someone could help me. I've created an InfoPath form and saved it as source files to get the .xsd file. Then I use xsd.exe to generate the C# file representing the form. I've done this before without any trouble, but now I've included a repeating table and now the WebMethod fails.

    I'm thinking either I don't go about populating the InfoPathFormService.group1 array or the InfoPathFormService.group2 objects which form part of that array, the right way. OR... perhaps the WebMethod doesn't like/permit having arrays as part of objects being returned.

    This is the signature of my method:


    [WebMethod]
    public InfoPathFormService.myFields GetExpense(string guid)
    {
    //...
    }


    The structure of the class is the following (I've cut out everything except the myFields, group1, and group2 declarations):


    namespace InfoPathFormService {

    public partial class myFields {
    private string nameField;
    private string dateField;
    private group2[] group1Field;
    //...
    }

    public partial class group1 {
    private group2[] group2Field;
    }

    public partial class group2 {
    private string projectNameField;
    //...
    }
    }


    I have gone about populating the fields of the object like this:


    InfoPathFormService.myFields singleExpense =
    new InfoPathFormService.myFields();

    // Fetch name and date
    string sql = "SELECT name, date FROM expense_sheet" +
    " WHERE guid='" + guid + "'";

    DataSet ds = QueryDB(QueryType.Query, sql);
    DataRow row = ds.Tables[0].Rows[0];

    singleExpense.name = row["name"].ToString();
    singleExpense.date = row["date"].ToString();

    // Fetch expense entries
    sql = "SELECT pname, pnumber, hotel, mileage, toll FROM expense_entry" +
    " WHERE guid='" + guid + "'";

    ds = QueryDB(QueryType.Query, sql);

    InfoPathFormService.group2 expGroup =
    new InfoPathFormService.group2();

    expGroup.projectName = "A project name";
    expGroup.projectNumber = "1003";

    singleExpense.group1.SetValue(expGroup, 0);


    Could someone please point me in the right direction?

    Thank you.
  • 01-03-2007 02:34 AM In reply to

    • fahlen
    • Not Ranked
    • Joined on 12-29-2006
    • Posts 7

    Re: Return complex type (rep. table) from WebService

    Really stupid error on my part. I had forgotten this line of code:

    singleExpense.group1 = new ExpenseInfoPathFormService.group2[1];


    However, one problem still remains, and I've been struggling with this one for some time. Whenever a field is of a type other than string in the class myFields, they are omitted in the WebMethod reply. Here's an example:


    <?xml version="1.0" encoding="utf-8" ?>
    - <myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-01-02T10:15:45">
    <name>Markus</name>
    <date>24/01/2007 0:00:00</date>
    - <group1>
    - <group2>
    <projectName>Nombre projecto</projectName>
    <projectNumber>1003</projectNumber>
    </group2>
    </group1>
    </myFields>


    group2 really has many more fields, but only projectName and projectNumber are of type string.
  • 01-03-2007 03:17 AM In reply to

    • fahlen
    • Not Ranked
    • Joined on 12-29-2006
    • Posts 7

    Re: Return complex type (rep. table) from WebService

    Sorry to have wasted your time. It so happens that all the string fields were marked as required (not allowed to be blank), but the fields of other types not. For these optional fields, I have to set the *Speciefied field to true, in order for it to be included in the SOAP message.

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