It's not a secret anymore!*
The moose likes Web Services and the fly likes Using java.lang.Arraylist object in WSAD WebServices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Using java.lang.Arraylist object in WSAD WebServices" Watch "Using java.lang.Arraylist object in WSAD WebServices" New topic
Author

Using java.lang.Arraylist object in WSAD WebServices

Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
Hello,
While trying to use java.lang.Arraylist object in WebServices, i encountered the following exception usint the Universal test Client genrated by WSAD:
exception: [SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to deserialize a 'http://util.java/:ArrayList' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalArgumentException: No Deserializer found to deserialize a 'http://util.java/:ArrayList' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]
Does any body know what i should do in order to use ArrayList in a WEbService, so I caon read it another platform (like .NET)?
Thank's,
Yair Ogen


Regards,<br /> <br />Yair Ogen
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
It seems unlikely that .NET will recognize a Java collection. Why not serialize a plain array?
Bill
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
How exactly can you serialize a simple array?
Do you mean like this: MyAccount[] (where "MyAccount" is a complex class of mine...)?
[ February 17, 2003: Message edited by: Yair Ogen ]
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Exactly!
You can pass arrays of primatives and your own complex types, they just need to be defined be soap data type compatible.
I started experimenting of Friday to see if I could "nest" complex types in other complex types. Initial test failed. I'll give it one more go before I discard it as "un-do-able". I'm also going to see if I can create a tree (node to node relationships) structure using a the same complex type.
Regards,


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
It all seems to work fine...
I was able to nest complex types (...I had a ValueObject class that contained an InnerValueObject class).
I was also able to create a tree or chain of my ValueObject where one ValueObject contains one or more references to one or more other ValueObjects.
...at least is WSAD via the generated proxy.
I'm about to generate a VB proxy for .Net to try it from there...
Regards,
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Only issue I had was when generating the proxy, I had to update my outer value object xsd to contain the "declaration" of the the inner value object and I had to place the xsd with the inner value object up one directory...
I'm still looking into why I was forced to do this... Initially I had issues with the two xsd files (inner and outer value objects having the same namespace.
Once I made those "odd" corrections based upon error messages generated by wsdl.exe I was able to invoke the vb proxy and return all the necessary values.
Regards,
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
Hi,
I'm probably missing something...
First I dont know what wsdl.exe is.
In fact when I try to use my generated wsdl in .NET for an inknown reason my xsd isn't passed on so my c# program doesn't recognize my complex object ("MyAccount") even if I'm not passing it as a simle array...
Besides the above I would to know what did you mean when you said: "they just need to be defined be soap data type compatible"?
As you can see my knowladge is poor...
Thus:
1. why doesn't my xsd file pass on?
2. what changes should I make tp pass simplar arrays of complex objects?
3. what is wsdl.exe and what is it for?
Thanks,
Yair
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
Hi I managed to create a .NET proxy but it can't "talk" to my java side application. I get the follwing error:
No Serializer found to serialize a org.apache.soap.rpc.Parameter using encoding style 'null'
from the java side.
what can I do to solve this.
this happens for complex objects as well as simple data types...
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
1) May I assume that you now know what the wsdl.exe is and what it's for and further that you built your .Net proxy using it?
2) show us the method signature of the webservice that is throwing the error.
Regards,
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
Yes, I have a clue of what wsdl.exe is and i built a .NET proxy.
The only problem with my .NET proxy is that it can't transfer or get parameters from my java side application (not even primitive data types).
I receive the following error message:
java.lang.IllegalArgumentException: No Serializer found to serialize a 'org.apache.soap.rpc.Parameter' using encoding style 'null'
In any case, here are some of the files involved:
here is the proxy:
*********************************************
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.0.3705.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
//
// This source code was auto-generated by wsdl, Version=1.0.3705.0.
//
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;

/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="WebserviceEjbBinding", Namespace="http://hrmsh.wsdl/WebserviceEjbBinding/")]
public class WebserviceEjbService : System.Web.Services.Protocols.SoapHttpClientProtocol {

/// <remarks/>
public WebserviceEjbService() {
this.Url = "http://localhost:8080/WebFoo/servlet/rpcrouter";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://tempuri.org/hrmsh.WebserviceEjb", ResponseNamespace="http://tempuri.org/hrmsh.WebserviceEjb")]
[return: System.Xml.Serialization.SoapElementAttribute("result")]
public string getStr() {
object[] results = this.Invoke("getStr", new object[0]);
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BegingetStr(System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("getStr", new object[0], callback, asyncState);
}

/// <remarks/>
public string EndgetStr(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://tempuri.org/hrmsh.WebserviceEjb", ResponseNamespace="http://tempuri.org/hrmsh.WebserviceEjb")]
[return: System.Xml.Serialization.SoapElementAttribute("result")]
public Err insertCategory(string primaryId) {
object[] results = this.Invoke("insertCategory", new object[] {
primaryId});
return ((Err)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BegininsertCategory(string primaryId, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("insertCategory", new object[] {
primaryId}, callback, asyncState);
}

/// <remarks/>
public Err EndinsertCategory(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((Err)(results[0]));
}
}
/// <remarks/>
[System.Xml.Serialization.SoapTypeAttribute("Err", "http://hrmsh/")]
public class Err {

/// <remarks/>
public string localizedMessage;

/// <remarks/>
public string message;

/// <remarks/>
public int errNum;

/// <remarks/>
public string trace;
}

*********************************************
here is the original remote interface of my bean:
[These are the methods in my web service...]
*********************************************
package hrmsh;
import hrmsh.MyAccount;
import hrmsh.Err;
/**
* Remote interface for Enterprise Bean: WebserviceEjb
*/
public interface WebserviceEjb extends javax.ejb.EJBObject
{
public MyAccount getMyAccount() throws java.rmi.RemoteException;

public Err insertCategory(String primaryId)
throws Err, java.rmi.RemoteException;
public String getStr() throws java.rmi.RemoteException;
}
*********************************************
here are the comlex classes:
*********************************************
package hrmsh;
import java.io.Serializable;
/**
* @author yairog
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class Err extends Throwable implements Serializable
{
private String message;
private String trace;
private int ErrNum;

public Err()
{
}

public Err(String message,String trace,int errNum)
{
setMessage(message);
setTrace(trace);
setErrNum(errNum);
}
/**
* Returns the errNum.
* @return int
*/
public int getErrNum() {
return ErrNum;
}
/**
* Returns the message.
* @return String
*/
public String getMessage() {
return super.getMessage();
}
/**
* Returns the trace.
* @return String
*/
public String getTrace() {
return trace;
}
/**
* Sets the errNum.
* @param errNum The errNum to set
*/
public void setErrNum(int errNum) {
ErrNum = errNum;
}
/**
* Sets the message.
* @param message The message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Sets the trace.
* @param trace The trace to set
*/
public void setTrace(String trace) {
this.trace = trace;
}
}

package hrmsh;
import java.io.Serializable;
/**
* @author Utxhr45
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class MyAccount implements Serializable
{
private int id;
private int accountNo;
private int counterNo;
private int transactionId;
private String creditOrDebit;
private int reference;
private double baseAmount;
private double shekelAmount;
private String securityCode;
private int matchNo;
private int storno;
private long eventNo;
private String details;
private String name;
private double balance;


public MyAccount()
{
setId(1);
setAccountNo(1);
setCounterNo(1);
setTransactionId(1);
setCreditOrDebit("c");
setReference(111111111);
setBaseAmount(9009);
setBaseAmount(232323);
setSecurityCode("DOLAR");
}

/**
* Returns the accountNo.
* @return int
*/
public int getAccountNo()
{
return accountNo;
}
/**
* Returns the balance.
* @return double
*/
public double getBalance()
{
return balance;
}
/**
* Returns the baseAmount.
* @return double
*/
public double getBaseAmount()
{
return baseAmount;
}
/**
* Returns the businessDate.
* @return Date
*/

/**
* Returns the counterNo.
* @return int
*/
public int getCounterNo()
{
return counterNo;
}
/**
* Returns the creditOrDebit.
* @return String
*/
public String getCreditOrDebit()
{
return creditOrDebit;
}

/**
* Returns the details.
* @return String
*/
public String getDetails()
{
return details;
}
/**
* Returns the eventNo.
* @return long
*/
public long getEventNo()
{
return eventNo;
}
/**
* Returns the id.
* @return int
*/
public int getId()
{
return id;
}
/**
* Returns the matchNo.
* @return int
*/
public int getMatchNo()
{
return matchNo;
}
/**
* Returns the name.
* @return String
*/
public String getName()
{
return name;
}
/**
* Returns the reference.
* @return int
*/
public int getReference()
{
return reference;
}

/**
* Returns the securityCode.
* @return String
*/
public String getSecurityCode()
{
return securityCode;
}
/**
* Returns the shekelAmount.
* @return double
*/
public double getShekelAmount()
{
return shekelAmount;
}
/**
* Returns the storno.
* @return int
*/
public int getStorno()
{
return storno;
}
/**
* Returns the transactionId.
* @return int
*/
public int getTransactionId()
{
return transactionId;
}

/**
* Sets the accountNo.
* @param accountNo The accountNo to set
*/
public void setAccountNo(int accountNo)
{
this.accountNo = accountNo;
}
/**
* Sets the balance.
* @param balance The balance to set
*/
public void setBalance(double balance)
{
this.balance = balance;
}
/**
* Sets the baseAmount.
* @param baseAmount The baseAmount to set
*/
public void setBaseAmount(double baseAmount)
{
this.baseAmount = baseAmount;
}

/**
* Sets the counterNo.
* @param counterNo The counterNo to set
*/
public void setCounterNo(int counterNo)
{
this.counterNo = counterNo;
}
/**
* Sets the creditOrDebit.
* @param creditOrDebit The creditOrDebit to set
*/
public void setCreditOrDebit(String creditOrDebit)
{
this.creditOrDebit = creditOrDebit;
}

/**
* Sets the details.
* @param details The details to set
*/
public void setDetails(String details)
{
this.details = details;
}
/**
* Sets the eventNo.
* @param eventNo The eventNo to set
*/
public void setEventNo(long eventNo)
{
this.eventNo = eventNo;
}
/**
* Sets the id.
* @param id The id to set
*/
public void setId(int id)
{
this.id = id;
}
/**
* Sets the matchNo.
* @param matchNo The matchNo to set
*/
public void setMatchNo(int matchNo)
{
this.matchNo = matchNo;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name)
{
this.name = name;
}
/**
* Sets the reference.
* @param reference The reference to set
*/
public void setReference(int reference)
{
this.reference = reference;
}

/**
* Sets the securityCode.
* @param securityCode The securityCode to set
*/
public void setSecurityCode(String securityCode)
{
this.securityCode = securityCode;
}
/**
* Sets the shekelAmount.
* @param shekelAmount The shekelAmount to set
*/
public void setShekelAmount(double shekelAmount)
{
this.shekelAmount = shekelAmount;
}
/**
* Sets the storno.
* @param storno The storno to set
*/
public void setStorno(int storno)
{
this.storno = storno;
}
/**
* Sets the transactionId.
* @param transactionId The transactionId to set
*/
public void setTransactionId(int transactionId)
{
this.transactionId = transactionId;
}

}
*********************************************
here are the generated xsd files:
*********************************************
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="qualified"
elementFormDefault="unqualified" targetNamespace="http://hrmsh/"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://hrmsh/">
<complexType name="Err">
<all>
<element name="localizedMessage" nillable="true" type="string"/>
<element name="message" nillable="true" type="string"/>
<element name="errNum" type="int"/>
<element name="trace" nillable="true" type="string"/>
</all>
</complexType>
</schema>

<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="qualified"
elementFormDefault="unqualified" targetNamespace="http://hrmsh/"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://hrmsh/">
<complexType name="MyAccount">
<all>
<element name="details" nillable="true" type="string"/>
<element name="name" nillable="true" type="string"/>
<element name="id" type="int"/>
<element name="balance" type="double"/>
<element name="creditOrDebit" nillable="true" type="string"/>
<element name="reference" type="int"/>
<element name="accountNo" type="int"/>
<element name="counterNo" type="int"/>
<element name="shekelAmount" type="double"/>
<element name="matchNo" type="int"/>
<element name="securityCode" nillable="true" type="string"/>
<element name="eventNo" type="long"/>
<element name="transactionId" type="int"/>
<element name="storno" type="int"/>
<element name="baseAmount" type="double"/>
</all>
</complexType>
</schema>
*********************************************
[ February 18, 2003: Message edited by: Yair Ogen ]
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Yair,
An observation...
Your .net proxy code does not contain your getAccount function call and does not contain the class definition for your myAccount class.
This stuff is not conceptually difficult, but it does require attention to detail and a strict following of the process to create them. Personally, most problems I've encountered have been because I've been in a hurry and forgotten a step, or skipped testing each piece along the way.
That can be frustrating.
I'll assume you've tested the webservice calling it from a java proxy and that it worked flawlessly.
I'll as assume that you created a web application in .net and had access to all the framework code you'd need to do SOAP calls.
If I were you I'd take a step backa and create a test class with the simplest api possible (one method call returning just a String or an int), no other clutter. I'd go through the steps of building and testing each step along the way, especially to make sure it's working in java before moving to .Net. Once you've proven that it works go back to your original class and go through the same steps. I'm sure you'll discover the error then...
Regards,
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
Sorry,
It still doesn't work. Not even for a simple String. Either I didn't use my .NET proxy correctly, or I have a compatability porblem between .NET and WSAD.
I found one topic regarding my problem at dotnet247 Forum which indicates that maybe the soap version used by WSAD (2.2) is incompatible with the version used by .NET. Does .NET use the 2.3 version?
Might that be the problem?
Yair Ogen
Greenhorn

Joined: Feb 12, 2003
Posts: 29
As for now the problem was solved by changing the soap jar to the soap jar v2.3 int the WSAD runtime...
If any body knows how I can integrate Axis in WSAD (as it is a better solution than an jar exchange), please let me know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using java.lang.Arraylist object in WSAD WebServices
 
Similar Threads
No Deserializer found to deserialize
msg=No Deserializer found to deserialize a ':return'
problem with SOAP
simple array in WSAD 5.0 web service. is it possible?
No Deserializer found error