Proper way to return a Dataset to InfoPath from a WebService

M

Mike Morisoli

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
 
J

Jan Tielens

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!
 
M

Mike Morisoli

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 said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top