我正在使用JAX-WS創建Web服務(我正在使用Java to WSDL方法創建此服務)。沒有出現在WSDL中的JAX-WS Soap故障
我無法讓我的異常工作,因爲我需要。
我創建了以下異常類:
@WebFault
public class MyWebServiceException extends SOAPFaultException {
private static final long serialVersionUID = 8234753208722614057L;
protected MyWebServiceException(SOAPFault fault) {
super(fault);
}
protected MyWebServiceException(SOAPFault fault, Throwable throwable) {
this(fault);
super.setStackTrace(throwable.getStackTrace());
}
}
這讓我在我的SOAP響應如下:
<faultcode>E0010</faultcode>
<faultstring>Invalid Report</faultstring>
<detail>
<ns2:exception class="com.example.web.common.exceptions.MyWebServiceException" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false" xmlns:ns2="http://jax-ws.dev.java.net/">
<message>Invalid Report</message>
<ns2:stackTrace>
<ns2:frame class="com.example.web.common.exceptions.ExceptionHandler" file="ExceptionHandler.java" line="34" method="getWebException"/>
但是,因爲我的例外是SOAPFaultException
延伸RuntimeException
,它不會被添加到WSDL中,因此當服務的用戶生成其客戶端存根時,不包括該異常。
有誰知道如何創建此異常給我想要的輸出(即包括在faultcode和faultstring),但也出現在WSDL(我猜它必須是經過檢查的異常)我搜索SO
高低來拿出我已經有的東西!
什麼是JAX-WS運行時? – 2013-03-13 19:40:29
您使用哪種JAX-WS實現來構建? – Nick 2013-03-18 18:03:04
'wsimport -version JDK 6中的JAX-WS RI 2.1.6' – cowls 2013-03-19 08:32:31