Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Abstract and derived complexTypes

843833Dec 21 2006 — edited Dec 22 2006
Hi,

I've been experimenting with various platforms that I can use to test some interop scenarios between .NET ASMX web services and Java clients and vice versa.

I got Sun Studio Ent. 8.1 for the client side of the house so far.

I use a contract first approach for service design, using XML Spy to define the types, request/response messages, and WSDL. Then use .NET's wsdl.exe to generate service side interface.

Anyways, my types.xsd has a PublicationType complex type defined as abstract. I derive MagazineType and BookType from that by extension.

I have a GetPublicationsResponse element in messages.xsd which has a Publications element whose type is PublicationType and unbounded, so essentially an array of PublicationType.

In a .NET to .NET scenario, everything works as I would expect, and can determine the concrete type at runtime:

foreach (PublicationType t in response.Publications)
{
if (t is MagazineType )
//
else if ( t is BookType )
//
}

I tried the same with a Java client in Sun Studio.

I created a new Java standalone app, added a main GUI form to it (apologies for the lack of Java terminology here), added a Web Service Client to the project. I pointed the Web Service Client at a physical WSDL file for the service, to get the contract first side of the client going.

I examined the generated .class(s) and noticed only PublicationType generated. So, I cannot examine the response message for MagazineType or BookType, and get this exception when I invoke the service operation:

Runtime exception; nested exception is:
unexpected element type: expected={http://wiseowlbooks.com/schemas/types.xsd}PublicationType, actual={http://wiseowlbooks.com/schemas/types.xsd}MagazineType

That's just from calling the service. If I didn't get an exception, I would code something similiar to the snip posted above to determine the concrete type.

Basically, is abstract complexTypes and derived types inappropriately used in this scenario?

On another note, I developed a client in JBuilder and got the expected results, in that I was able to iterate the collection of PublicationType in the response, and determine their concrete implementation.

Thanks,
Ron
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2007
Added on Dec 21 2006
1 comment
178 views