Proper way to return a Dataset to InfoPath from a WebService

Discussion in 'ASP .Net Web Services' started by Mike Morisoli, Apr 24, 2004.

  1. I am trying to figure out the proper way to return a .net dataset to
    InfoPath so that it likes it and the schema looks normal.

    InfoPath seems to want pure standard XML, nothing else. IP SP1 can read a
    standard .NET dataset, but the structure is very strange
    and convoluted.

    Here are some examples that don't work. I am hoping that someone has done
    this before and knows a simple way. The only other examples I have found
    take the dataset and walk thru it one row at a time creating a series of
    arrays and returning an arrary structure for the dataset.

    Example 1:

    [WebMethod( Description = "Returns a list of all the Axapta vendors we are
    authorized to purchase from. Typically used to fill dropdown list
    boxes." )]
    public DataSet GetAuthorizedVendors()
    {
    DataSet ds =
    SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["ConnectionString
    "], "GetAuthorizedVendors");
    return ds;
    }

    I have tried to convert the ds into an XML document using this method, which
    is better, but still produces a strange schema.

    [WebMethod( Description = "Returns an xml list of all the Axapta vendors we
    are authorized to purchase from. Typically used to fill dropdown list
    boxes." )]
    public XmlDataDocument GetAuthorizedVendorsXML()
    {
    XmlDataDocument xmlDoc = new XmlDataDocument(this.GetAuthorizedVendors());
    return xmlDoc;
    }

    The only other examples I have seen create a series of array elements which
    require a ton of code and will be hard to maintain.

    Can anyone provide me with some better ways to go?

    Thanks for your time, Mike
     
    Mike Morisoli, Apr 24, 2004
    #1
    1. Advertising

  2. Mike Morisoli

    Jan Tielens Guest

    Mike

    I'd go with custom classes instead of DataSets... The guidelines tell us
    that DataSets don't fit well into interop. scenarios. For example InfoPath
    doesn't like them, but also BizTalk for example works easier with serialized
    custom classes. What you can do is:
    - Create the InfoPath form (start from scratch, no data connections)
    - Extract the XSD from the XSN file
    - Use the XSD.EXE tool to generate classes for that XSD
    - Use those classes as a return value of your web service

    This should save you some work!

    --
    Greetz,
    Jan
    ________________________
    Read my weblog: http://weblogs.asp.net/jan

    "Mike Morisoli" <> schreef in bericht
    news:%...
    > I am trying to figure out the proper way to return a .net dataset to
    > InfoPath so that it likes it and the schema looks normal.
    >
    > InfoPath seems to want pure standard XML, nothing else. IP SP1 can read a
    > standard .NET dataset, but the structure is very strange
    > and convoluted.
    >
    > Here are some examples that don't work. I am hoping that someone has done
    > this before and knows a simple way. The only other examples I have found
    > take the dataset and walk thru it one row at a time creating a series of
    > arrays and returning an arrary structure for the dataset.
    >
    > Example 1:
    >
    > [WebMethod( Description = "Returns a list of all the Axapta vendors we are
    > authorized to purchase from. Typically used to fill dropdown list
    > boxes." )]
    > public DataSet GetAuthorizedVendors()
    > {
    > DataSet ds =
    >

    SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["ConnectionString
    > "], "GetAuthorizedVendors");
    > return ds;
    > }
    >
    > I have tried to convert the ds into an XML document using this method,

    which
    > is better, but still produces a strange schema.
    >
    > [WebMethod( Description = "Returns an xml list of all the Axapta vendors

    we
    > are authorized to purchase from. Typically used to fill dropdown list
    > boxes." )]
    > public XmlDataDocument GetAuthorizedVendorsXML()
    > {
    > XmlDataDocument xmlDoc = new

    XmlDataDocument(this.GetAuthorizedVendors());
    > return xmlDoc;
    > }
    >
    > The only other examples I have seen create a series of array elements

    which
    > require a ton of code and will be hard to maintain.
    >
    > Can anyone provide me with some better ways to go?
    >
    > Thanks for your time, Mike
    >
    >
     
    Jan Tielens, Apr 24, 2004
    #2
    1. Advertising

  3. Jan, thanks, I was looking at this very thing last night in some of my old
    ..NET books that I skipped over before, so your advice confirms this is the
    way to go.

    Need to check if Whidbey is going to have any new methods to simplify the
    interop delivery of these type of data sources.

    Thanks again.

    Mike


    "Jan Tielens" <> wrote in message
    news:...
    > Mike
    >
    > I'd go with custom classes instead of DataSets... The guidelines tell us
    > that DataSets don't fit well into interop. scenarios. For example InfoPath
    > doesn't like them, but also BizTalk for example works easier with

    serialized
    > custom classes. What you can do is:
    > - Create the InfoPath form (start from scratch, no data connections)
    > - Extract the XSD from the XSN file
    > - Use the XSD.EXE tool to generate classes for that XSD
    > - Use those classes as a return value of your web service
    >
    > This should save you some work!
    >
    > --
    > Greetz,
    > Jan
    > ________________________
    > Read my weblog: http://weblogs.asp.net/jan
    >
    > "Mike Morisoli" <> schreef in bericht
    > news:%...
    > > I am trying to figure out the proper way to return a .net dataset to
    > > InfoPath so that it likes it and the schema looks normal.
    > >
    > > InfoPath seems to want pure standard XML, nothing else. IP SP1 can read

    a
    > > standard .NET dataset, but the structure is very strange
    > > and convoluted.
    > >
    > > Here are some examples that don't work. I am hoping that someone has

    done
    > > this before and knows a simple way. The only other examples I have

    found
    > > take the dataset and walk thru it one row at a time creating a series of
    > > arrays and returning an arrary structure for the dataset.
    > >
    > > Example 1:
    > >
    > > [WebMethod( Description = "Returns a list of all the Axapta vendors we

    are
    > > authorized to purchase from. Typically used to fill dropdown list
    > > boxes." )]
    > > public DataSet GetAuthorizedVendors()
    > > {
    > > DataSet ds =
    > >

    >

    SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["ConnectionString
    > > "], "GetAuthorizedVendors");
    > > return ds;
    > > }
    > >
    > > I have tried to convert the ds into an XML document using this method,

    > which
    > > is better, but still produces a strange schema.
    > >
    > > [WebMethod( Description = "Returns an xml list of all the Axapta vendors

    > we
    > > are authorized to purchase from. Typically used to fill dropdown list
    > > boxes." )]
    > > public XmlDataDocument GetAuthorizedVendorsXML()
    > > {
    > > XmlDataDocument xmlDoc = new

    > XmlDataDocument(this.GetAuthorizedVendors());
    > > return xmlDoc;
    > > }
    > >
    > > The only other examples I have seen create a series of array elements

    > which
    > > require a ton of code and will be hard to maintain.
    > >
    > > Can anyone provide me with some better ways to go?
    > >
    > > Thanks for your time, Mike
    > >
    > >

    >
    >
     
    Mike Morisoli, Apr 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MJ
    Replies:
    4
    Views:
    6,214
    Mr Newbie
    Oct 7, 2005
  2. =?Utf-8?B?Q29zaW1vIEdhbGFzc28=?=

    Download an xml infopath form from an web page

    =?Utf-8?B?Q29zaW1vIEdhbGFzc28=?=, Nov 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    793
    =?Utf-8?B?Q29zaW1vIEdhbGFzc28=?=
    Nov 10, 2005
  3. Sven Steinacker
    Replies:
    1
    Views:
    742
    Johannes Koch
    Oct 27, 2003
  4. Sven Steinacker
    Replies:
    0
    Views:
    698
    Sven Steinacker
    Oct 27, 2003
  5. Mattias Larson

    InfoPath + XSL

    Mattias Larson, Dec 11, 2003, in forum: XML
    Replies:
    0
    Views:
    515
    Mattias Larson
    Dec 11, 2003
Loading...

Share This Page