Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Proper way to return a Dataset to InfoPath from a WebService

Reply
Thread Tools

Proper way to return a Dataset to InfoPath from a WebService

 
 
Mike Morisoli
Guest
Posts: n/a
 
      04-23-2004
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.App Settings["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


 
Reply With Quote
 
 
 
 
Jan Tielens
Guest
Posts: n/a
 
      04-24-2004
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" <(E-Mail Removed)> schreef in bericht
news:%(E-Mail Removed)...
> 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.App Settings["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
>
>



 
Reply With Quote
 
 
 
 
Mike Morisoli
Guest
Posts: n/a
 
      04-24-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> schreef in bericht
> news:%(E-Mail Removed)...
> > 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.App Settings["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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper way to check malloc return Billy Mays C Programming 37 06-09-2010 11:33 AM
Proper way to wait for menu command and return? RajW C Programming 9 03-05-2006 02:38 PM
Download an xml infopath form from an web page =?Utf-8?B?Q29zaW1vIEdhbGFzc28=?= ASP .Net 0 11-10-2005 06:06 PM
InfoPath 12: Replacement for ASP.NET web forms? MJ ASP .Net 4 10-07-2005 08:15 PM
proper way to return errors to parent process junky_fellow@yahoo.co.in C Programming 2 03-01-2005 06:15 AM



Advertisments