简体   繁体   English

WSDL中未提及的抛出SOAP错误

[英]Throw SOAP Fault not mentioned in WSDL

I am using contract first approach to publish a web service using JAX-WS. 我正在使用契约优先方法来使用JAX-WS发布Web服务。 There are no SOAP fault in the WSDL, but the existing web service throws fault exceptions appropriately. WSDL中没有SOAP错误,但是现有的Web服务会适当地引发错误异常。

I am unable to throw similar fault exception as the service method I am implementing now asks to add throws clause. 我无法抛出类似的故障异常,因为我正在实现的服务方法要求添加throws子句。

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? 如果我对您的理解正确,那么您在问如何将抛出的异常添加到wsdl中?

There are a few reasons why a thrown exception doesn't show up in a generated wsdl 有几个原因导致所生成的wsdl中未显示引发的异常

  1. The thrown exception is not a checked exception, for example because you subclassed it from a RuntimeException which is an unchecked exception. 引发的异常不是受检查的异常,例如,因为您从RuntimeException继承了子类,RuntimeException是未经检查的异常。
  2. You did not add throws MyException to your webservice method (you caught the exception instead). 您没有将throws MyException添加到Webservice方法中(而是捕获了异常)。
  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). 有人说您必须在异常类中添加@WebFault批注 ,但是根据我的经验,这不是必需的(可能取决于您使用的jax-ws版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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