Skip to main content

JAX-WS web service return ElementNSImpl

4 replies [Last post]
laurentapo
Offline
Joined: 2007-07-26

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lehrian
Offline
Joined: 2008-01-07

I'm having the same issue. Did you ever get a solution?

lehrian
Offline
Joined: 2008-01-07

I have the answer to this issue. The problem is that ALL the complex objects you are attempting to marshall and unmarshall aren't defined in the client. I was including my DTO library in my client, but I didn't realize that it wasn't using those objects to unmarshall the XML, instead it was creating it's own set of DTO objects based on the @XmlSeeAlso tag. I had to include ALL my DTO classes in the @XmlSeeAlso tag, rebuild the web service and launch it. Then I had to have my client resync it's copy of the WSDL and when I rebuilt the client application it generated its own set of DTO objects that it was able to use to unmarshall the XML. I am using Netbeans 6.0.1 to do this. I hope this saves someone the hours it took me to figure it out.

salford
Offline
Joined: 2008-04-10

Hi,
I have the same problem with this error
javax.xml.bind.JAXBException: java.util.ArrayList nor any of its super class is known to this context.

Your explanation is not quite clear to me. sorry i am newbebie, what is DTO and how do you include that to SeeAlso annotations.

lehrian
Offline
Joined: 2008-01-07

Hello Salford,
A DTO is a Data Transfer Object used to pass data from the server to the client. See http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.... for a full explaination. The DTO's are populated with data from the EJB's and passed to my client via the web service call. The web service call marshalls them via JAXB on the server and unmarshalls them on the client. But in order for these objects to be unmarshalled on the client, the DTO class needs to be defined on the client. I had initially thought that putting the DTO's in a library and including that library in the client would be the way to get them defined on the client. However, so the client doesn't have to have the server libraries linked in, JAXB uses special annotations to tell the web service what objects are used buy the interface so the client can generate the DTO's from the web service interface itself. So to make the client aware of the DTO classes it needs you use the SeeAlso annotation at the beginning of your web service call. e.g.

@WebService()
@XmlSeeAlso({AddressDTO.class,CompanyDTO.class,ContactDTO.class})
public class EBXViewer {
.
.
.
}

But now that I wrote this explaination, I'm not sure this is the fix for the ArrayList because I thought that ArrayList was one of the base types that is supported by JAXB. Your answer may be simply annotating your ArrayList to tell it the type of objects that the list is going to contain like ArrayList myList = new ArrayList(); If the ArrayList contains more complex objects you will need to include the complex objects in the @XmlSeeAlso list. You could try including ArrayList.class in the @XmlSeeAlso list, but I don't think this will fix your problem. I think that annotating the ArrayList with the type of objects it will contain is your answer.

Whatever change you make, be sure to rebuild the web service, launch it, refresh the client from the web service and clean and rebuild the client. Be sure to clean and rebuild the client as that will delete any previously generated client source code.