• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Working With Complex Data Types

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BackGround:
With all the help and documentation available online i have been able to get startedp and make a fair amount of progress with implementing web services in Java 6. So, far I had been able to have my webmethod return primitive types such as string etc and even had luck with Vector and ArrayList.

Problem: Unable to figure out how to have the webmethod return more complex data types such as an vector of vectors or arraylist of arraylists or arraylist of a certain custom java class object.

My webservice client is a java servlet, which after making the call simply forwards the call to a JSP page after setting the returned complex data type as the HttpSession variable. On the JSP page, i am unable to retreive the complex data type. The errors I see are either that the current context doesnt know about the POJO class that i have written on the server or trouble unmarshalling the complex data type.

Components used: netbeans 6.0, jax-ws, glassfishv2.

Alternatives Known: Axis from apache heard allows for handling complex data types & Java objects.

With the amount of time invested in using Jax-ws, Im looking for help to get complex data types / objects around. All the examples I found are always dealing with simpler types.

Any help in getting me an idea or pointer to understand working with complex data types will be much appreciated!

Thanks
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch,

Please check your private messages.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eye Geek:
Im looking for help to get complex data types / objects around.



That is where your problem is - XML can represent complex data but not "objects". There is no equivalent for Vectors and Arraylists in XML Schema - it has a "sequence" which is mapped to an array in Java. Furthermore non-Java web service consumers would have no idea what java.util.Vector and java.util.Arraylist are. Futhermore XML, being hierarchical in nature, has difficulties representing complex, possibly cyclical object graphs.

SOAP is not a remote object access protocol - it's an XML-based messaging protocol.

Have look at contract first development and "Item 43: Recognize the object-hierarchical impedance mismatch" in Effective Enterprise Java: Ch.5: State Management (PDF)
 
Venkat Ram
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peer. You are right. Once I am thinking of transferring Java Objects using webservices, then I am not making it interoperable with other all SOAP clients. Thanks for the schema document, it helped.

For the record, I was able to get the java object transferred using jax-ws. With Netbeans, using Jax-WS and transferring java object almost feels like RMI or Corba where stubs are created on the client side. Netbeans was actually getting all the classes from the server side that are needed for using the object on the client side when pointing to the Webservice operation / wsdl file.

But, now that I figured this could be done using Jax-WS. I will now move on implementing a complex data using xml schema that soap supports and can work with other soap clients.

Thanks again.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Venkat Ram:
Thanks Peer. You are right. Once I am thinking of transferring Java Objects using webservices, then I am not making it interoperable with other all SOAP clients. Thanks for the schema document, it helped.

For the record, I was able to get the java object transferred using jax-ws. With Netbeans, using Jax-WS and transferring java object almost feels like RMI or Corba where stubs are created on the client side. Netbeans was actually getting all the classes from the server side that are needed for using the object on the client side when pointing to the Webservice operation / wsdl file.

But, now that I figured this could be done using Jax-WS. I will now move on implementing a complex data using xml schema that soap supports and can work with other soap clients.

Thanks again.



I am also facing the similar scenario where i want to pass my entity bean as return type of my web service, but I am getting cyclical reference error while validating the WSDL file. I am using Netbeans 6.1 to create Web Services and Web service clients.
Can you guide me as to how can I get rid of cyclical reference errors and send the entity bean as response back to the calling client? Can I do that? If not, then How can i send the complex data back to the client?

Thanks
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chin desai:
send the entity bean as response back to the calling client? Can I do that? If not, then How can i send the complex data back to the client?



If your client could use the entity bean in the first place wouldn't you just use EJB rather than web services? A SOAP web service client and service exchange SOAP requests and responses that carry XML payloads. The complex data is captured in the XML document.

This topic might be of some interest.
[ November 18, 2008: Message edited by: Peer Reynders ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm a newbie to java. i need to develop a web service to get and set customer information (customer id, name, address and phone number). in my case address is the complex data type and it includes home number, street and town. can any body give a sample for this so then i can easily figure out how this works. regards.

ushan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic