簡體   English   中英

WSDL中的Axis2 WebService和多個ExceptionFault元素

[英]Axis2 WebService and multiple ExceptionFault elements in WSDL

我不是AXIS2專家,因此我正在使用Eclipse生成自底向上的Web服務。 我正在發布2種方法作為Web服務。 定義這些方法以引發java.lang.Exception,以便在調用以異常結尾的webservice時產生SOAPFault。

public class sample {

 public String someMethod() throws Exception {
  throw new CustomException("Error: blabla");
 }


 public String someOtherMethod() throws Exception {
  throw new CustomException("Error: blabla");
 }

}

發布Web服務后,一切正常。 但是AXIS2生成的WSDL似乎是缺陷。 有2個ExceptionFault元素(每個方法一個?),這對於某些Web服務客戶端是有問題的。

<xs:element name="ExceptionFault">
   <xs:complexType>
      <xs:sequence>
         <xs:element name="Exception" nillable="true" type="xs:anyType"/>
      </xs:sequence>
   </xs:complexType>
</xs:element>

問題是什么? 我的實現有問題嗎? 我也試圖聲明直接拋出CustomException或拋出Exception的方法,但是沒有成功...

馬丁

如果您從方法簽名中刪除“ throws Exception”,它將不會生成帶有Exception元素的WSDL。

如果您的CustomException擴展了RuntimeException(即它是未經檢查的異常),那么您會很好的。 Axis會將RuntimeException正確地轉換為SOAPFault。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM