File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes CONSUMING .NET DATASET IN JAVA CLIENT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "CONSUMING .NET DATASET IN JAVA CLIENT" Watch "CONSUMING .NET DATASET IN JAVA CLIENT" New topic
Author

CONSUMING .NET DATASET IN JAVA CLIENT

Shaji Ravindran
Ranch Hand

Joined: Jan 12, 2002
Posts: 39
Hi,
I need a help.My problem is that i have to use a web service which is built in .net and returns dataset from there web methods, i have to consume these in my client which has to be built using java, could any one suggest in which way it can be done.
I'd be gratefull if any body can provide any code samples.
Thanks in advance.
[ January 09, 2004: Message edited by: Shaji Ravindran ]
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
WHY SO URGENT ???
Inspite of .net or java or php every webservice will have its services described in WSDL file format.
Apache axis has the option of reading this WSDL file and create the client code for you. All you to do is re-code this auto generated client code to suite your user-end needs.
Check aApche axis for more info.


Spritle Software Blogs
Shaji Ravindran
Ranch Hand

Joined: Jan 12, 2002
Posts: 39
Thanks for the response.Iam trying with axis for last few days but not sucessfull yet,if u have any code sample in axis, pls post it.
Thanks
[ January 09, 2004: Message edited by: Shaji Ravindran ]
[ January 20, 2004: Message edited by: Shaji Ravindran ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Axis comes with many code samples. See the Apache Website. You have to give us more information to go on to be able to help you. Simply saying "it doesn't work" doesn't help.
What steps have you done? What exceptions (if any) are you getting? Have you RTFM (e.g. the Apache Axis documentation and the JAX-RPC specification)?
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Shaji Ravindran
Ranch Hand

Joined: Jan 12, 2002
Posts: 39
Hi,
Thanks for the response. I found an example of such java client in axis/test/wsdl/dataset folder which iam posting below,it returns an object , but iam not getting any idea how to get real data from the Result object.

package test.wsdl.dataset;
import org.apache.axis.AxisFault;
import java.net.ConnectException;
import java.io.IOException;
public class DataServiceTestCase extends junit.framework.TestCase {
public DataServiceTestCase(java.lang.String name) {
super(name);
}
public void test1DataServiceSoapGetTitleAuthors() throws Exception {
test.wsdl.dataset.DataServiceSoapStub binding;
try {
binding = (test.wsdl.dataset.DataServiceSoapStub)new test.wsdl.dataset.DataServiceLocator().getDataServiceSoap();
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
jre.getLinkedCause().printStackTrace();
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
assertTrue("binding is null", binding != null);
binding.setTimeout(60000);

try {
// Test operation
test.wsdl.dataset._GetTitleAuthorsResponse_GetTitleAuthorsResult value = null;
value = binding.getTitleAuthors();
assertTrue(value != null);
// TBD - validate results
} catch (java.rmi.RemoteException re) {
if (re instanceof AxisFault) {
AxisFault fault = (AxisFault) re;
if (fault.detail instanceof ConnectException ||
fault.getFaultCode().getLocalPart().equals("HTTP")) {
System.err.println("DataService HTTP error: " + fault);
return;
}
if (fault.detail instanceof IOException) {
System.err.println("DataService IO error: " + fault);
return;
}
}
throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
}
}
}
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
it returns an object , but iam not getting any idea how to get real data from the Result object.
Without seeing the interface of that result object, all I can say is "with the result object's methods". How about just calling each method and printing whatever they return so that you can see which piece of data comes out from which method?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Shaji Ravindran:

test.wsdl.dataset._GetTitleAuthorsResponse_GetTitleAuthorsResult value = null;
=>=> value = binding.getTitleAuthors();
assertTrue(value != null);
// TBD - validate results
}

The above code shows its returning a the value for AuthorsTitle..
If you know want what else you can get from the data set, then you have run WSDL2Java for the given dataset WSDL, this will generate all the necessary stubs file, then you have to go-thorough this stub files to see which is connector class, data objects class, interfaces etc.,
The java code(DataServiceTestCase) that you see at test/wsdl/dataset is just a snippet and not the complete code.
[ January 16, 2004: Message edited by: Balaji Loganathan ]
Shaji Ravindran
Ranch Hand

Joined: Jan 12, 2002
Posts: 39
hi all,
Thanks for the response.Has any one developed any similar application who can provide some code snippet or example which shows how to extract the values from the result object.Below is the java file which is the returned object, this is generated with wsdl2java.
package org.tempuri;
public class _GetTitleAuthorsResponse_GetTitleAuthorsResult implements java.io.Serializable {
private org.apache.axis.message.MessageElement [] _any;
public _GetTitleAuthorsResponse_GetTitleAuthorsResult() {
}
public org.apache.axis.message.MessageElement [] get_any() {
return _any;
}
public void set_any(org.apache.axis.message.MessageElement [] _any) {
this._any = _any;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof _GetTitleAuthorsResponse_GetTitleAuthorsResult)) return false;
_GetTitleAuthorsResponse_GetTitleAuthorsResult other = (_GetTitleAuthorsResponse_GetTitleAuthorsResult) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this._any==null && other.get_any()==null) ||
(this._any!=null &&
java.util.Arrays.equals(this._any, other.get_any())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (get_any() != null) {
for (int i=0;
i<java.lang.reflect.Array.getLength(get_any());
i++) {
java.lang.Object obj = java.lang.reflect.Array.get(get_any(), i);
if (obj != null &&
!obj.getClass().isArray()) {
_hashCode += obj.hashCode();
}
}
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(_GetTitleAuthorsResponse_GetTitleAuthorsResult.class);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://tempuri.org/", ">GetTitleAuthorsResponse>GetTitleAuthorsResult"));
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
Thanks
[ January 16, 2004: Message edited by: Shaji Ravindran ]
[ January 16, 2004: Message edited by: Shaji Ravindran ]
 
jQuery in Action, 2nd edition
 
subject: CONSUMING .NET DATASET IN JAVA CLIENT