Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hierarchical exception handling in WSDL  RSS feed

 
toto huang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Does anyone know that WSDL support hierarchical exception at all ? if it does, how do we define it in the WSDL file, so that the client (Java/.NET/etc) will be able to handle the exception correctly in different level.

E.g A and B are Exception subclasses.
B extends A.
when I generate the WSDL from a method that throws both exception, it only take exception A into account, and ignoring exception B. This make the client side could not handle exception B correctly since they are not aware about exception B at all.

Any help would be much appreciated.

Thanks.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by toto huang:
Does anyone know that WSDL support hierarchical exception at all ?


I suspect that your problem isn't with WSDL but with the Java-To-WSDL code generation.

The code generation simply sees "myMethod () throws A" and uses that to base the WSDL on, totally ignoring the fact that there are subclasses of A in existence.

If the hierarchy is important to you then you can design the WSDL contract first and use the XML Schema "extension type" to create the inherited type used in the WSDL message that is bound to the SOAP fault. Personally I wouldn't use "advanced XML Schema" features because there is no guarantee that the prospective web service client can support them. And extension, restriction, polymorphism, enumerations, lists and unions are considered advanced XML Schema. XML is simply semi-structured data - not a programming language.

So you are probably better off by flatting your exception hierarchy which forces you to declare "myMethod () throws A,B".


With all the hubbub about web services and loose coupling a WSDL that is produced by tools or that can be used by tools to completely automate the XML (un)marshalling will introduce tight coupling (See: I Hate WSDL).

A WSDL that uses "any" or "anytype" is more loosely coupled but forces the programmer to deal with XML directly (xsd:any: A cautionary tale) because the structure of the data in question is no longer part of the WSDL/XSD contract.
 
toto huang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peer Reynders, that's a very comprehensive explanation..and it gives me an understanding about how these all things relate to each other and the boundaries. I may go with flattening the exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!