简体   繁体   中英

Throw SOAP Fault not mentioned in WSDL

I am using contract first approach to publish a web service using JAX-WS. There are no SOAP fault in the WSDL, but the existing web service throws fault exceptions appropriately.

I am unable to throw similar fault exception as the service method I am implementing now asks to add throws clause.

I could find this question as related one.

If I understood you correctly, you are asking how to add the thrown exception to your wsdl?

There are a few reasons why a thrown exception doesn't show up in a generated wsdl

  1. The thrown exception is not a checked exception, for example because you subclassed it from a RuntimeException which is an unchecked exception.
  2. You did not add throws MyException to your webservice method (you caught the exception instead).
  3. Some people say that you have to add the @WebFault annotation to your exception class, but in my experience this isn't required (perhaps it depends on the jax-ws version you use).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM