Forums Register Login

CONSUMING .NET DATASET IN JAVA CLIENT

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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);
}
}
}
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
 

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 ]
+Pie Number of slices to send: Send
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 ]
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 7163 times.
Similar Threads
receiving xml from one dataset in .Net
Which Java SOAP library for .NET access?
Convert ResultSet - > Xml with Xml Schema in java
How to build a java client using weblogic api to invoke Asynchronous .Net web Servic
Convert ResultSet - > Xml with Xml Schema in java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:22:35.