aspose file tools*
The moose likes Web Services and the fly likes problem in generating stubs with java.util.List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "problem in generating stubs with java.util.List " Watch "problem in generating stubs with java.util.List " New topic
Author

problem in generating stubs with java.util.List

Ravi Majety
Ranch Hand

Joined: Feb 26, 2009
Posts: 59

hi,I am facing the problem in creating the stubs for an wsdl file. Actually, the webmethods are implemented using the generic collections like they made use of java.util.List and java.util.Map . At time of generation of wsdl file using the java, we got the following element defined for java.util.List.

At time of creating the stubs using wscompile, it is creating the seperate List class instead considering it as java.util.List. So please provide me the solution in generating the stubs with Generic Collections.


<xsd:schema xmlns:stns="java:language_builtins.util"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified"
targetNamespace="java:language_builtins.util"
elementFormDefault="qualified">
<xsd:complexType name="List">
<xsd:sequence>
<xsd:element maxOccurs="unbounded"
nillable="true"
name="anyType"
type="xsd:anyType"
minOccurs="0">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Rudy Gireyev
Ranch Hand

Joined: May 03, 2011
Posts: 39
If you use Java Collections as your return types you will essentially require that the users of your Web Services use Java only to access your services. Since no other language is guaranteed to have those Collections available. If you use Arrays on the other hand then anyone will be able to use your Web Services.

Rudy
Ravi Majety
Ranch Hand

Joined: Feb 26, 2009
Posts: 59

Hi Rudy, i understood your answer but here we are using the java on both the ends. i mean webservice is developed using java and at client side also , we are making use of java. But i am unable to bind the List variable to java.util.List .

Because the at time of generating the stubs , as the List is defined as complex element in wsdl, the jwsdp is considering it as a seperate class and genearating the seperate class with name List, due to which i am unable to bind the response object to java.util.List. as here jwsdp is considering the response object is an instace List class(a stub which is generated by jwsdp using wsdl file)

Hope you understood my focus. So please provide me the solution into this.

Rudy Gireyev wrote:If you use Java Collections as your return types you will essentially require that the users of your Web Services use Java only to access your services. Since no other language is guaranteed to have those Collections available. If you use Arrays on the other hand then anyone will be able to use your Web Services.

Rudy
Rudy Gireyev
Ranch Hand

Joined: May 03, 2011
Posts: 39
I'm unaware of SOAs ability to support Java Collections. Maybe someone else knows better though. However, if you really want to work with List you can simply do the following.
1. Use List.toArray() - to turn your List into an Array
2. Arrays.asList(Object[]) - to turn an Array into a List

Here's a link that discusses the issues with using Collections with SOA:
http://www.ibm.com/developerworks/webservices/library/ws-tip-coding/index.html

Rudy
Ravi Majety
Ranch Hand

Joined: Feb 26, 2009
Posts: 59

Hi Rudy, I am very happy for getting a fast response from you. I understood your approach. I know that only use of arrays would be useful in webservices inplace of collections. But I like to whether is there any other solutions to customize the mapping of this complex type List to java.util.List.


Rudy Gireyev wrote:I'm unaware of SOAs ability to support Java Collections. Maybe someone else knows better though. However, if you really want to work with List you can simply do the following.
1. Use List.toArray() - to turn your List into an Array
2. Arrays.asList(Object[]) - to turn an Array into a List

Here's a link that discusses the issues with using Collections with SOA:
http://www.ibm.com/developerworks/webservices/library/ws-tip-coding/index.html

Rudy
suraj aryan
Greenhorn

Joined: Nov 19, 2010
Posts: 17
check all the namespaces url you have used and the binding element .It must be java.util.List
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in generating stubs with java.util.List