使用Jax生成代理Web服务客户端时出错

时间:2011-06-02 01:47:45

标签: java web-services jax-ws

我想知道我是否可以在以下问题上获得一些帮助。

我试图使用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>

首先,我做错了什么?最后,如果没有办法生成代理客户端,那么有没有其他方式来访问这个Web服务&它是java中的方法。 我是Java的新手,所以任何帮助都会非常感激。

谢谢

2 个答案:

答案 0 :(得分:11)

您可以将XMLschema作为参数传递给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

答案 1 :(得分:4)

你是如何创建WSDL的?它会引用您引用未在WSDL中导出的某些数据类型。

修改
wsdl引用名为's'的模式但是找不到它,因为它的URL是
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