First of all, SOAP is not my web service protocol of choice since I think it is overkill for the most of applications. I prefer the simplest possible solution for the problem, but when the service that you need is only available through SOAP, you don’t have much choice.
The fact is that .NET developers like SOAP and use it as a de-facto the only way to expose their services. Simplicity to do so is certainly one of the most important factors in this decision. While there is nothing generally wrong with this, the simplicity hides some traps for those that don’t take care. One such trap is making methods return (or accept parameters) of general types such as ADO.NET DataSet (something like JDBC ResultSet in Java).
In order to explain what kind of problems you can expect in this case, let’s recapitulate the process of creating a Java client for arbitrary web service (using Apache Axis). Usually, you will get WSDL file from your service provider defining the service. Next, you will run WSDL2Java tool which will create stub classes that abstracts service methods and their arguments (and return values).
From that point on things are straightforward, since you are back in the Java world. Axis library did its job of abstracting the web service and providing you with ability to use regular Java objects to handle data through SOAP protocol.
In case that your service provider has chosen to pass DataSet objects through SOAP calls, the above scenario falls apart and you’re left on your own. The problem is that WSDL2Java tool cannot create proper stub classes for this general type, so you will get MessageElement object and you have to find your way to deal with it.
There is even an MSDN article that suggests to .NET developers that these practices are bad and that they will lead to broken “toolkit-compatibility”. This particular article even suggests a few techniques that could be used instead of sending raw DataSets in order to avoid this kind of problems.
But if you have a web service that exposes DataSet in its interface and cannot change that, what should you do? Theoretically, solution is simple: all you have to do is to make your code know how to format and parse valid XML representation of DataSet objects. Since the MessageElement class that you will get by your stub classes is the implementation of the DOM Element interface, you can use the DOM API to finish this work. The hard part is that syntax of these datasets is complex. I found this article as a good resource for introduction to this topic.
So, if your potential service provider didn’t start work on its web service, make sure that he reads these articles so that you can save a few days of hard work. For all others, these articles could be solid guides for general direction of their solutions. I hope that there will be some tool available soon that will bridge this functionality (if nothing else, I’ll try to find some time to write one).


"The fact is that .NET developers like SOAP and use it as a de-facto the only way to expose their services. "
Ohh, boy you should learn .NET
Was this posted correctly? Check out windowsdevcenter.com.
The fact that MS suggests not to use datasets when exposing webservices says all.
I've been exactly in the situation exposed in the article (it was the hell!). By knowing the element's names, and using the getChildren() method and the getObjetcValue(Class) method of MessageElement do the work nicely.
Its important to remark that get_any()[0] is the schema of the dataset (trash), and get_any[1] is the diffgram in which the data to fill the beans resides.
Hope it helps... and please, Mr Gates, for once in your live, visit the w3c web and read a little.
Hi Steve, I'm in this exact same situation now and it appears as the link (http://tools.devchannel.org/devtoolschannel/04/07/09/1650215.shtml?tid=21&tid=46)
is dead, redirecting to linux.com
Do you know of any other resource which may be a good reference on how to get around this?
I am going through hell. I have googled for a whole week but no solution. I am able to consume the Dataset as suggested above but the REAL problem is that the .Net web service method also takes a Dataset parameter. Axis generated a stub class for the Dataset which has the constructor as follows:
public UploadChangesDs(
org.apache.axis.message.MessageElement [] _any) {
this._any = _any;
}
Could you PLEASE suggest how can I fill the 'UploadChangesDs' and call the .Net web service method which takes a Dataset.
I am desperate and I will be really grateful.
Thanks