Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

de/serializers for ArrayLists

 
Sam Bom
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scenario ..if someone
could help me here...
Following is the class method I'm using which returns an ArrayList which I want to receive in my .Net setup.
public class AddFunction1 {
public AddFunction1(){}
public ArrayList searchUsers(String lastName, String firstName)
{
ArrayList myList = new ArrayList();
if(lastName.equals("last") && firstName.equals("first"))
myList.add(0, "mg1");
else
myList.add(0, "mg2");
return myList;
}
}
This is how my deploy.wsdd looks like which deploys the webservice okay in my AxisRc2 (in which some fixes have been done for the ArrayLists)
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="AddFunction1Service" provider="java:RPC">
<parameter name="className" value="AddFunction1"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:ArrayList" xmlns:myNS="urn:BeanService"
languageSpecificType="java:java.util.ArrayList"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java rg.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="java rg.apache.axis.transport.local.LocalResponder"/>
</responseFlow>
</transport>
</deployment>
But I've not been able to get this inside my .Net client(Web Service Toolkit).Althogh I can see the proxy stubs and skeletons generated in .Net
and also the ArrayList object which is not null but still it doesn't show the correct data within it..
Has someone encountered such problem?
thanks
Sam.
 
Ramesh Nagappan
Author
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sam Bom:
I have a scenario ..if someone
could help me here...
Following is the class method I'm using which returns an ArrayList which I want to receive in my .Net setup.
public class AddFunction1 {
public AddFunction1(){}
public ArrayList searchUsers(String lastName, String firstName)
{
ArrayList myList = new ArrayList();
if(lastName.equals("last") && firstName.equals("first"))
myList.add(0, "mg1");
else
myList.add(0, "mg2");
return myList;
}
}
This is how my deploy.wsdd looks like which deploys the webservice okay in my AxisRc2 (in which some fixes have been done for the ArrayLists)
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="AddFunction1Service" provider="java:RPC">
<parameter name="className" value="AddFunction1"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:ArrayList" xmlns:myNS="urn:BeanService"
languageSpecificType="java:java.util.ArrayList"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java rg.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="java rg.apache.axis.transport.local.LocalResponder"/>
</responseFlow>
</transport>
</deployment>
But I've not been able to get this inside my .Net client(Web Service Toolkit).Althogh I can see the proxy stubs and skeletons generated in .Net
and also the ArrayList object which is not null but still it doesn't show the correct data within it..
Has someone encountered such problem?
thanks
Sam.

It would be easy to identify, if you put the WSDL !
 
Sam Bom
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramesh This is my generated wsdl
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://workstation-12:8080/axis/services/AddFunction1Service" xmlns:intf="http://workstation-12:8080/axis/services/AddFunction1Service" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:BeanService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://workstation-12:8080/axis/services/AddFunction1Service">
<wsdl:types>
<schema targetNamespace="urn:BeanService" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayList">
<sequence>
<complexContent>
<extension base="soapenc:Array">
</extension>
</complexContent>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="searchUsersResponse">
<wsdl:part name="searchUsersReturn" type="tns1:ArrayList"/>
</wsdl:message>
<wsdl:message name="searchUsersRequest">
<wsdl:part name="in0" type="xsd:string"/>
<wsdl:part name="in1" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="AddFunction1">
<wsdlperation name="searchUsers" parameterOrder="in0 in1">
<wsdl:input name="searchUsersRequest" message="impl:searchUsersRequest"/>
<wsdlutput name="searchUsersResponse" message="impl:searchUsersResponse"/>
</wsdlperation>
</wsdl:portType>
<wsdl:binding name="AddFunction1ServiceSoapBinding" type="impl:AddFunction1">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdlperation name="searchUsers">
<wsdlsoapperation/>
<wsdl:input>
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace"/>
</wsdl:input>
<wsdlutput>
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://workstation-12:8080/axis/services/AddFunction1Service"/>
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="AddFunction1Service">
<wsdl:port name="AddFunction1Service" binding="impl:AddFunction1ServiceSoapBinding">
<wsdlsoap:address location="http://workstation-12:8080/axis/services/AddFunction1Service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably the problem is that .NET does not know about ArrayList since it is a Java collection. Why not just send an array of String?
The collections API has these great methods for conversion to and from arrays, so I really don't see any reason to get tangled up in Java specific classes.
String[] ret = new String[ myList.size() ];
return myList.toArray( ret );
should work.
 
Sam Bom
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya Coneverting to Arrays is a good option,but I'm dealing with an existing application and the client is reluctant to change the method signatures snd definitions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic