2011-07-27 33 views
3

我已經編寫了一個WSDL來生成存根和骨架,但是我的骨架不會在eclipse中生成。我使用Eclipse的Helios版本。
任何人都可以告訴WSDL有什麼問題嗎?無法從WSDL生成存根/ java骨架

我想使用Axis 2.我也嘗試使用wsdl2java生成骨架,但它在生成的類中給出了編譯問題。我無法在這裏附加文件,所以我在這裏粘貼它。

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<wsdl:definitions xmlns:impl="http://DefaultNamespace" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap" 
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     name="Test" targetNamespace="http://DefaultNamespace"> 
     <wsdl:types> 
     <xsd:schema elementFormDefault="qualified" 
      targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema"> 
      <import namespace="http://xml.apache.org/xml-soap" /> 
      <xsd:element name="serviceMethod"> 
      <xsd:complexType> 
       <xsd:sequence> 
       <xsd:element name="vo" type="impl:MyVo" /> 
       </xsd:sequence> 
      </xsd:complexType> 
      </xsd:element> 
      <xsd:complexType name="MyVo"> 
      <xsd:sequence> 
       <xsd:element name="name" nillable="false" type="xsd:string" /> 
       <xsd:element name="params" nillable="true" 
       type="apachesoap:Map" /> 
      </xsd:sequence> 
      </xsd:complexType> 
      <xsd:element name="serviceMethodResponse"> 
      <xsd:complexType> 
       <xsd:sequence> 
       <xsd:element name="serviceMethodReturn" type="impl:MyVo" /> 
       </xsd:sequence> 
      </xsd:complexType> 
      </xsd:element> 
     </xsd:schema> 
     <xsd:schema elementFormDefault="qualified" 
      targetNamespace="http://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema"> 
      <import namespace="http://DefaultNamespace" /> 
      <xsd:complexType name="mapItem"> 
      <xsd:sequence> 
       <xsd:element name="key" nillable="true" type="xsd:anyType" /> 
       <xsd:element name="value" nillable="true" type="xsd:anyType" /> 
      </xsd:sequence> 
      </xsd:complexType> 
      <xsd:complexType name="Map"> 
      <xsd:sequence> 
       <xsd:element maxOccurs="unbounded" minOccurs="0" 
       name="item" type="apachesoap:mapItem" /> 
      </xsd:sequence> 
      </xsd:complexType> 
     </xsd:schema> 
     </wsdl:types> 
     <wsdl:message name="serviceMethodRequest"> 
     <wsdl:part element="impl:serviceMethod" name="parameters" /> 
     </wsdl:message> 
     <wsdl:message name="serviceMethodResponse"> 
     <wsdl:part element="impl:serviceMethodResponse" name="parameters" /> 
     </wsdl:message> 
     <wsdl:portType name="Test"> 
     <wsdl:operation name="serviceMethod"> 
      <wsdl:input message="impl:serviceMethodRequest" name="serviceMethodRequest" /> 
      <wsdl:output message="impl:serviceMethodResponse" name="serviceMethodResponse" /> 
     </wsdl:operation> 
     </wsdl:portType> 
     <wsdl:binding name="TestSOAP" type="impl:Test"> 
     <soap:binding style="document" 
      transport="http://schemas.xmlsoap.org/soap/http" /> 
     <wsdl:operation name="serviceMethod"> 
      <soap:operation soapAction="http://DefaultNamespace/serviceMethod" /> 
      <wsdl:input> 
      <soap:body use="literal" /> 
      </wsdl:input> 
      <wsdl:output> 
      <soap:body use="literal" /> 
      </wsdl:output> 
     </wsdl:operation> 
     </wsdl:binding> 
     <wsdl:service name="Test"> 
     <wsdl:port binding="impl:TestSOAP" name="MyWebService"> 
      <soap:address location="http://localhost:8080/Temp/services/MyService" /> 
     </wsdl:port> 
     </wsdl:service> 
    </wsdl:definitions> 
+0

適合我的作品和編譯。你的錯誤信息究竟是什麼? – bdares

+0

您是否嘗試使用eclipse或wsdl2java生成骨架?當我嘗試使用eclipse時,它不會在嚮導中顯示服務名稱,端口名稱,並給出「在WSDL的代碼生成期間發生的異常:java.lang.NoClassDefFoundError:com/ibm/wsdl/extensions/schema/SchemaImportImpl「用於Axis2。 –

回答

1

這是您的安裝問題。

下載並驗證axis2和axis2 eclipse插件,確保已經設置了AXIS2_HOME類路徑。

有時它也停止爲我工作,然後我必須去重新安裝所有東西。不要打擾向Eclipse或Apache發出錯誤報告,它們總是以「WORKSFORME」關閉。

步驟,從您的WSDL生成代碼:

  1. 創建動態Web項目。
  2. 創建您的wsdl文件。
  3. 在您的WSDL文件單擊鼠標右鍵,選擇Web服務 - >生成的Java Bean骷髏
  4. 單擊Finish

Axis2的庫面,和生成的代碼會被自動地添加到您的項目中,有將不會有彙編問題。

+0

你能告訴你使用哪個eclipse版本和哪個axis2版本? –

+0

我使用jdk 1.5,eclipse helios,axis2 1.5.4,axis2 codegen插件1.5.4。 – bdares

+0

謝謝bdares:嗯,我能夠生成骨架類,但是當我將這些類添加到項目中時,它會在新生成的類中顯示編譯錯誤。你有沒有嘗試把它們放在項目中?我在生成的「MapItem」類中看到5個編譯錯誤。 –

1

我有同樣的問題。我相信maven文件夾結構正在導致它。我創建了一個沒有maven的新項目,它工作。稍後添加maven。在「Java構建路徑」中檢查源文件夾。如果缺少,您需要添加它。

+0

這並沒有真正回答這個問題。如果您有不同的問題,可以通過單擊[提問](http://stackoverflow.com/questions/ask)來提問。您還可以[添加賞金](http://stackoverflow.com/help/privileges/set-bounties)在您擁有足夠的[聲譽](http://stackoverflow.com/help/)時吸引更多人關注此問題什麼聲譽)。 – cfi

+0

我回答了這個問題。我遇到了這個問題,並且我描述瞭如果你仔細閱讀,我是如何解決它的。 –

+0

您有類似(或相同)的症狀,但顯然是一個不同的問題:請注意,在您回答前四個月,bdares回答了原始提問者接受的解決方案。你的解決方案可能是一個有效的解決方案,但對於另一個問題。你發佈的內容是一項寶貴的貢獻,但僅作爲評論,恕我直言。爲了使這個網站對未來的訪問者有意義,我們必須嘗試區分類似症狀的不同問題。如果所有類似症狀的問題都以一個問題結束,那麼最終該網站將會變得非常混亂。 – cfi

0

我面臨同樣的麻煩,但現在已經解決了。問題是如果你有一種方法'拋出某種特殊情況',那麼它會導致這個問題。因此,不要拋出錯誤,請嘗試使用try-catch塊語句。