2011-06-02 140 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

相关问题