0

On the server-side I create an object called Fragment. Lets just say it is a data container for some Strings.

A simple WebMethod which takes a String and returns another is fairly straightforward and easy to implement. But if I try to send an object from server to client it gets complicated. I publish the WebService and use wsimport to create my client stub classes.

I want to return a set of Fragments to the client. wsimport creates a HashSet class that is the return-type of the method which calls the respective-server method.

I can't cast this HashSet to a standard java util HashSet how do I process such complex objects?

Edit: This is the signature of the method published by the webservice:

@WebMethod
public HashSet<Fragment> topicIntersect(File tm1, String loc1, File tm2,
        String loc2)

This is what wsimport generated:

/**
 * 
 * @param arg3
 * @param arg2
 * @param arg1
 * @param arg0
 * @return
 *     returns webservice.HashSet
 */
@WebMethod
@WebResult(partName = "return")
public HashSet topicIntersect(
    @WebParam(name = "arg0", partName = "arg0")
    String arg0,
    @WebParam(name = "arg1", partName = "arg1")
    String arg1,
    @WebParam(name = "arg2", partName = "arg2")
    String arg2,
    @WebParam(name = "arg3", partName = "arg3")
    String arg3);

webservice.HashSet is an also generated empty class with no methods...

Stephan
  • 1,639
  • 3
  • 15
  • 26

1 Answers1

1

I'm not sure if JAX-WS supports HashSet directly. However, List will certainly work. In addition, if you use a code first approach, you don't need to generate client stubs. You should be able to use the same interface that your service implements.

Andreas Veithen
  • 8,868
  • 3
  • 25
  • 28
  • it doesn't support HashSet and List either... thats why theese stub classes (webservice.hashset) are created. What do you mean with "code-first-approach"? – Stephan Nov 07 '11 at 13:59
  • "Code first" means that you start by implementing the service in Java and then generate the WSDL from it. Apparently you then use that WSDL to generate a client stub. That approach (generating client code from a generated WSDL) is sometimes used with Axis2 (ADB client stubs for POJO services), but it is not the right approach for JAX-WS. – Andreas Veithen Nov 07 '11 at 16:06
  • do you have any recommendations where I can read this stuff up? A small tutorial or a little implementation example? – Stephan Nov 07 '11 at 22:47
  • The following question has a couple of links to JAX-WS tutorials and documentation: http://stackoverflow.com/questions/1533118/getting-started-with-jax-ws – Andreas Veithen Nov 08 '11 at 20:37