2011-06-02 76 views
5

我想知道是否可以得到一些幫助解決以下問題。使用Jax生成代理Web服務客戶端時出錯

我試圖運行下面使用JAX生成Web服務客戶端代理的命令:

wsimport http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

但我發現了以下錯誤:

Microsoft Windows [Version 6.1.7601] 
Copyright (c) 2009 Microsoft Corporation. All rights reserved. 

C:\Users\Asher>wsimport http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 
parsing WSDL... 


[WARNING] src-resolve.4.2: Error resolving component 's:schema'. It was detected that 's:schema' is in namespace 'http:/ 
/www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'http://www.h 
olidaywebservice.com/Holidays/HolidayService.asmx?WSDL#types?schema1'. If this is the incorrect namespace, perhaps the p 
refix of 's:schema' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be ad 
ded to 'http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL#types?schema1'. 
    line 15 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL#types?schema1 

[ERROR] undefined element declaration 's:schema' 
    line 15 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

[ERROR] undefined element declaration 's:schema' 
    line 36 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

[ERROR] undefined element declaration 's:schema' 
    line 74 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

[ERROR] undefined element declaration 's:schema' 
    line 97 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

[ERROR] undefined element declaration 's:schema' 
    line 120 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

[ERROR] undefined element declaration 's:schema' 
    line 131 of http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 


C:\Users\Asher> 

首先我做錯東西不正確?最後,如果沒有辦法生成代理客戶端,那麼有沒有其他的方式來訪問這個webservice &它是java中的方法。 我是仙女新的Java所以任何幫助將不勝感激。

謝謝

回答

4

你是如何創建WSDL的?它認爲你引用了一些未在WSDL中導出的數據類型。

編輯
的WSDL指的是一個名爲 'S' 模式,但這不能被發現,因爲它的網址是
http://www.w3.org/2001/XMLSchema而應該是
http://www.w3.org/2001/XMLSchema.XSD

更改後,現在它也抱怨http://www.27seconds.com/Holidays/也沒有指向一個架構。您需要將它們全部修復到您的WSDL副本中,然後使用它進行wsimport。

我也去www.holidaywebservice.com,發現有在第二個版本: http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?wsdl

+0

我沒有創建WSDL那麼傷心,我有沒有對其進行控制。 – zSynopsis 2011-06-02 13:44:00

+0

編輯帖子,根據你的評論回答。 – 2011-06-02 17:04:30

10

您可以通過XML模式作爲參數上的wsimport

wsimport -b http://www.w3.org/2001/XMLSchema.xsd http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 

有架構中的潛在名稱衝突的架構。 一種解決方法是創建customization.xjb具有以下

<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" version="2.0"> 
<globalBindings> 
<xjc:simple/> 
</globalBindings> 
<bindings scd="~xsd:complexType"> 
<class name="ComplexTypeType"/> 
</bindings> 
<bindings scd="~xsd:simpleType"> 
<class name="SimpleTypeType"/> 
</bindings> 
<bindings scd="~xsd:group"> 
<class name="GroupType"/> 
</bindings> 
<bindings scd="~xsd:attributeGroup"> 
<class name="AttributeGroupType"/> 
</bindings> 
<bindings scd="~xsd:element"> 
<class name="ElementType"/> 
</bindings> 
<bindings scd="~xsd:attribute"> 
<class name="attributeType"/> 
</bindings> 
</bindings> 

你的終極召喚就會

wsimport -b http://www.w3.org/2001/XMLSchema.xsd -b customization.xjb http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL 
+0

感謝您使用XMLSchema.xsd作爲wsimport參數的提示,我已經忘記了這一點,它解決了我今天的問題:) – ThierryB 2012-11-08 12:07:35

+0

我有同樣的問題,並解決它,非常感謝! – user1452076 2013-09-25 20:09:42

相關問題