470,620 Members | 1,606 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,620 developers. It's quick & easy.

DataSet and Platform Dependency

Hi,

We are having a debate over using DataSet as return value type for web
services.

The problem is that we don't know whether Java applications can use DataSet
or not.

Can we count on the fact that java supplications can consume asp.net web
services that return Dataet?

If the answer is NO, then what is the best practice? What it the best way to
return table structure data from a asp.net web service to a Java based
client?

A link to online resource will solve our problem.

Any help would be appreciated,

Max
Oct 3 '06 #1
13 2181
Hello Max,

From your description, you're developing a webservice which will return
datas from tables in backend database and currently you're meet problem on
determine how to return the data to webservice client, through dataset or
other XML format, correct?

As you mentioned that your webservice will be visited by other non-DOTNET
platform, I think using DataSet does will cause some interopability issue.
Actually, you're not totally prohibited from using DataSet, you can return
those data as a DataSet with dataTables, and they'll be serialized as XML
content, and the webservice client can correctly accept such XML content
(in SOAP message). However, the problem here is that those non-dotnet
client(such as java) can not have a corresponding class like DataSet, so it
can not derserialize the DataSet's XML content back into object instance.
And in such cases, you can only use the DataSet as a normal XML Document
and use XML api(such as DOM) to query data items from it.

I'm not sure whether O-R mapping is adoptable here for your scenario. It is
common that we created some custom classes(with properties) to represent
data tables in datatable. And when we query records from database table, we
convert them as custom class's instance collection and return those custom
class object collection to client. Also, for both dotnet or non-dotnet
webservice platform, there're interfaces for mapping custom class to a
certain XML format (just like the XML Serialization in .net), you can
define a contract between service and client so that your .net custom
classes will be serialized as certain format of XML content and the
non-dotnet client can also deserialize them to class instances.

Here are some web reference discussing on such topics(called contract-first
webservice design-pattern):

#Contract-First Web Services with Apache Axis2
http://today.java.net/pub/a/today/20...b-services-wit
h-axis2.html

#Techniques for Contract-First Development
http://msdn.microsoft.com/msdnmag/is...erviceStation/

#Contract First Web Services Interoperability between Microsoft .NET and
IBM WebSphere
http://msdn.microsoft.com/vstudio/ja...p/default.aspx

Hope this helps some.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.



Oct 3 '06 #2
Hello,

I recently had to integrate a .NET Web Service with a Progress application.
The Web Service passed a DataSet to the Progress app. Someone else took care
of the Progress side but basically Progress provide a thing called Open
Client which allows the ceration od References as dll's which can be
incorporated into the .NET project to allow calls to be made between .NET and
Progress apps. This allows for easy passing of objects such as DataSets. It
worked very well. There may well be a tool for Java which does something
similar. In fact, it may be more likely seeing as Java is a bit more popular
than Progress nowadays, however that is just a guess.

hth in some way,

Best ,
David

"Maxwell2006" wrote:
Hi,

We are having a debate over using DataSet as return value type for web
services.

The problem is that we don't know whether Java applications can use DataSet
or not.

Can we count on the fact that java supplications can consume asp.net web
services that return Dataet?

If the answer is NO, then what is the best practice? What it the best way to
return table structure data from a asp.net web service to a Java based
client?

A link to online resource will solve our problem.

Any help would be appreciated,

Max
Oct 4 '06 #3
Hi David,

Thank you for help. Your scenario works perfect in windows platform;
however, I am not sure that you can do the same in AIX or Solaris. Our
client doesn't want to be bound to windows platform.

Thank you,

Max

"David++" <Da***@discussions.microsoft.comwrote in message
news:80**********************************@microsof t.com...
Hello,

I recently had to integrate a .NET Web Service with a Progress
application.
The Web Service passed a DataSet to the Progress app. Someone else took
care
of the Progress side but basically Progress provide a thing called Open
Client which allows the ceration od References as dll's which can be
incorporated into the .NET project to allow calls to be made between .NET
and
Progress apps. This allows for easy passing of objects such as DataSets.
It
worked very well. There may well be a tool for Java which does something
similar. In fact, it may be more likely seeing as Java is a bit more
popular
than Progress nowadays, however that is just a guess.

hth in some way,

Best ,
David

"Maxwell2006" wrote:
>Hi,

We are having a debate over using DataSet as return value type for web
services.

The problem is that we don't know whether Java applications can use
DataSet
or not.

Can we count on the fact that java supplications can consume asp.net web
services that return Dataet?

If the answer is NO, then what is the best practice? What it the best way
to
return table structure data from a asp.net web service to a Java based
client?

A link to online resource will solve our problem.

Any help would be appreciated,

Max

Oct 4 '06 #4
Hi,

Another thing I did which might work is to pass the DataSet as a string of
XML. For example -

[WebMethod]
public string GetDataSetAsStringOfXml()
{
DataSet ds = new DataSet();

// Populate the DataSet with data

// Get the XML for the dataset and load into a string
string s = ds.GetXml();

// returnthe string
return s;
}

Now, Java should understand the string? I have no experience in your
platform so I dont know. But, once you have the string you can then write it
as XML, and then you essentially have the DataSet and all its data in XML
format. Then Java can read that XML file and construct Java version of
DataSet.

Or perhaps Java can read the string of xml directly -

readXml
public void readXml(java.lang.String xml)Loads DataSet data from an XML
Document in String format; when complete, the DataSet will have been
populated from the Document.

Parameters:
xml - The XML Document, as a String.

But, I dont know for sure what is the best way or best practise. Still
learning here!

David

"Maxwell2006" wrote:
Hi David,

Thank you for help. Your scenario works perfect in windows platform;
however, I am not sure that you can do the same in AIX or Solaris. Our
client doesn't want to be bound to windows platform.

Thank you,

Max

"David++" <Da***@discussions.microsoft.comwrote in message
news:80**********************************@microsof t.com...
Hello,

I recently had to integrate a .NET Web Service with a Progress
application.
The Web Service passed a DataSet to the Progress app. Someone else took
care
of the Progress side but basically Progress provide a thing called Open
Client which allows the ceration od References as dll's which can be
incorporated into the .NET project to allow calls to be made between .NET
and
Progress apps. This allows for easy passing of objects such as DataSets.
It
worked very well. There may well be a tool for Java which does something
similar. In fact, it may be more likely seeing as Java is a bit more
popular
than Progress nowadays, however that is just a guess.

hth in some way,

Best ,
David

"Maxwell2006" wrote:
Hi,

We are having a debate over using DataSet as return value type for web
services.

The problem is that we don't know whether Java applications can use
DataSet
or not.

Can we count on the fact that java supplications can consume asp.net web
services that return Dataet?

If the answer is NO, then what is the best practice? What it the best way
to
return table structure data from a asp.net web service to a Java based
client?

A link to online resource will solve our problem.

Any help would be appreciated,

Max


Oct 4 '06 #5
Since DataSet is a .NET-specific type, you should return something platform
independent.

The earlier poster's suggestion about returning ds.GetXml() will work in
many cases (though I generally recommend against returning XML strings as
CDATA blocks - define a schema and return XML that matches the schema
instead).

In some cases, with multiple tables, the output of GetXml isn't going to
make much sense to your client. In that case, you may want to return the
DataSet as a sequence of the individual tables.

And, again, schema, schema, schema...

John
Oct 4 '06 #6
I agree that manipulate the DataSet's output xml as plain XML content
(through standard XML api) is a reasonable means if you do not want to
define custom business classes to mapping database table/rows as I
mentioned in the last reply.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 9 '06 #7
You know, the problem would be solved if MS would just provide a way to
serialize the schema of the DataSet to a 'non-MS' schema that could be used
by anyone (any language). While it looks like it's cleaner in .NET 2.0, it's
still not there.

David McCarter
VB.NET MVP
"Steven Cheng[MSFT]" wrote:
I agree that manipulate the DataSet's output xml as plain XML content
(through standard XML api) is a reasonable means if you do not want to
define custom business classes to mapping database table/rows as I
mentioned in the last reply.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights
Oct 9 '06 #8
"dotNetDave" <do********@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
You know, the problem would be solved if MS would just provide a way to
serialize the schema of the DataSet to a 'non-MS' schema that could be
used
by anyone (any language). While it looks like it's cleaner in .NET 2.0,
it's
still not there.
What's wrong with the schema?

John
Oct 9 '06 #9
This issue is that it has Microsoft or DataSet specific tags in it. To me, to
be truly interoperable, the WSDL or schema should be very generic, i.e. no
indication what language created it. You can read more of what I mean on my
blog:

http://blog.davidmccarter.net/PermaL...2d14b80e6.aspx

David

"John Saunders" wrote:
"dotNetDave" <do********@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
You know, the problem would be solved if MS would just provide a way to
serialize the schema of the DataSet to a 'non-MS' schema that could be
used
by anyone (any language). While it looks like it's cleaner in .NET 2.0,
it's
still not there.

What's wrong with the schema?

John
Oct 10 '06 #10
"John Saunders" wrote:
Since DataSet is a .NET-specific type, you should return something platform
independent.

The earlier poster's suggestion about returning ds.GetXml() will work in
many cases (though I generally recommend against returning XML strings as
CDATA blocks - define a schema and return XML that matches the schema
instead).

In some cases, with multiple tables, the output of GetXml isn't going to
make much sense to your client. In that case, you may want to return the
DataSet as a sequence of the individual tables.

And, again, schema, schema, schema...

John
Hi John,

Thanks for the tips. I'm curious to know what form would the returned XML
would take?When you say -

"define a schema and return XML that matches the schema instead"

How would you do this?

I'm aware that Web Services are ultimately SOAP messages which are XML and
the data within is always serialized and wrapped in XML, but when you go to
return the DataSet as a generic type, in what form would your DataSet be
returned?

Many thanks for any further info.
Best,
David
Oct 11 '06 #11
"David++" <Da***@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
"John Saunders" wrote:
>Since DataSet is a .NET-specific type, you should return something
platform
independent.

The earlier poster's suggestion about returning ds.GetXml() will work in
many cases (though I generally recommend against returning XML strings as
CDATA blocks - define a schema and return XML that matches the schema
instead).

In some cases, with multiple tables, the output of GetXml isn't going to
make much sense to your client. In that case, you may want to return the
DataSet as a sequence of the individual tables.

And, again, schema, schema, schema...

John

Hi John,

Thanks for the tips. I'm curious to know what form would the returned XML
would take?When you say -

"define a schema and return XML that matches the schema instead"

How would you do this?

I'm aware that Web Services are ultimately SOAP messages which are XML and
the data within is always serialized and wrapped in XML, but when you go
to
return the DataSet as a generic type, in what form would your DataSet be
returned?
David, the simple answer is, "create a sensible schema and then build the
XML to return however you like". Of course, that's too simple.

First of all, be aware that you can have your web service method return
XmlElement. I don't have time to look for it, but there's an article on this
on MSDN.

Second, given that you can return an XmlElement, you can return whatever XML
you like.

Third, if you had a schema, then you might "like" to return XML matching the
schema.

So, basically, your web service method becomes a matter of creating the XML
you'd like to return (however you like to do this), and then returning it.

I've personally used several different mechanisms to build the XML to
return, sometimes more than one in the same method. For instance, one method
built up the skeleton of the response using XmlDocument.CreateElement /
..AppendChild, and then part of the contents were filled in with XML
serialization. Some of the contents are created by taking the result of an
XML transform.

The bottom line is that you don't need to be a slave to how .NET wants to
serialize (or deserialize) XML into and out of .NET data types. You can use
XML directly and take control of the process.

This is especially interesting in your case, where you're trying to return
"a DataSet" to clients which have no concept of a DataSet (DataSet being
specific to .NET). Instead, define a schema which represents the data as
you'd like the clients to see it. This could, for instance, be a
denormalized form (clients which don't know about DataSet are less likely to
be able to resolve child relations).
I hope that helps, and doesn't make it worse!

John

P.S. I _do_ have to admit, that I had a learning curve to get over before I
could do this for my web service. I hadn't done much more than read XML
Schema before, so I had to do some research. It was worth it, though!
Oct 11 '06 #12
"John Saunders" wrote:
"David++" <Da***@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
"John Saunders" wrote:
Since DataSet is a .NET-specific type, you should return something
platform
independent.

The earlier poster's suggestion about returning ds.GetXml() will work in
many cases (though I generally recommend against returning XML strings as
CDATA blocks - define a schema and return XML that matches the schema
instead).

In some cases, with multiple tables, the output of GetXml isn't going to
make much sense to your client. In that case, you may want to return the
DataSet as a sequence of the individual tables.

And, again, schema, schema, schema...

John
Hi John,

Thanks for the tips. I'm curious to know what form would the returned XML
would take?When you say -

"define a schema and return XML that matches the schema instead"

How would you do this?

I'm aware that Web Services are ultimately SOAP messages which are XML and
the data within is always serialized and wrapped in XML, but when you go
to
return the DataSet as a generic type, in what form would your DataSet be
returned?

David, the simple answer is, "create a sensible schema and then build the
XML to return however you like". Of course, that's too simple.

First of all, be aware that you can have your web service method return
XmlElement. I don't have time to look for it, but there's an article on this
on MSDN.

Second, given that you can return an XmlElement, you can return whatever XML
you like.

Third, if you had a schema, then you might "like" to return XML matching the
schema.

So, basically, your web service method becomes a matter of creating the XML
you'd like to return (however you like to do this), and then returning it.

I've personally used several different mechanisms to build the XML to
return, sometimes more than one in the same method. For instance, one method
built up the skeleton of the response using XmlDocument.CreateElement /
..AppendChild, and then part of the contents were filled in with XML
serialization. Some of the contents are created by taking the result of an
XML transform.

The bottom line is that you don't need to be a slave to how .NET wants to
serialize (or deserialize) XML into and out of .NET data types. You can use
XML directly and take control of the process.

This is especially interesting in your case, where you're trying to return
"a DataSet" to clients which have no concept of a DataSet (DataSet being
specific to .NET). Instead, define a schema which represents the data as
you'd like the clients to see it. This could, for instance, be a
denormalized form (clients which don't know about DataSet are less likely to
be able to resolve child relations).
I hope that helps, and doesn't make it worse!

John

P.S. I _do_ have to admit, that I had a learning curve to get over before I
could do this for my web service. I hadn't done much more than read XML
Schema before, so I had to do some research. It was worth it, though!
Hi John,

Thanks for the reply and information. I think this topic is really important
to the discussion of real use of web Services as this type of thing is
ultimately going to crop up quite often so it is good to have some discussion
about it, so thanks a lot for sharing your knowledge! I think it is time for
me to go through the learning curve now with this issue, so thanks for giving
me some stuff to get going..

Cheers,
David
Oct 12 '06 #13
Hi Maxwell,

This might be a bit too late for you - I read your post only today - but
here are some ideas if you're still interested.

You shouldn't return a Dataset from a web service, among other things for
the reasons you've mentioned. However, you could use a Dataset on the inside
and have it returned pure XML - without any notion of MS or Datasets - by
creating a clean XSD Schema containing exactly what you want to transfer.

Before filling the new dataset, attach the XSD Schema to it. This makes
ADO.NET build the dataset's structure in accordance with the schema. Then
fill the dataset, binding SQL columns to dataset columns.

To return the content of the dataset as pure XML, based on the schema,
declare an XMLDoc variable (retVal). Then set that variable to point on a new
XMLDataDocument based on the dataset. Finally just return retVal from the web
service.

A drawback is that the WSDL won't publish the schema, you'll have to do that
by other means. The WSDL data type is just XML.

You could also consider using XSD.EXE to generate one or more message
classes from your schema. Long term, this is probably a better solution.

"Maxwell2006" wrote:
Hi,

We are having a debate over using DataSet as return value type for web
services.

The problem is that we don't know whether Java applications can use DataSet
or not.

Can we count on the fact that java supplications can consume asp.net web
services that return Dataet?

If the answer is NO, then what is the best practice? What it the best way to
return table structure data from a asp.net web service to a Java based
client?

A link to online resource will solve our problem.

Any help would be appreciated,

Max
Oct 19 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by pervinder | last post: by
3 posts views Thread by news.microsoft.com | last post: by
6 posts views Thread by Jumping Matt Flash | last post: by
15 posts views Thread by Joseph Geretz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.