【问题标题】:Error when using Jax to generate Proxy web service client使用 Jax 生成 Proxy Web 服务客户端时出错
【发布时间】:2011-06-02 01:47:45
【问题描述】:

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

我正在尝试使用 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 很陌生,所以任何帮助都将不胜感激。

谢谢

【问题讨论】:

    标签: java web-services jax-ws


    【解决方案1】:

    您可以将 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
    

    【讨论】:

    • 感谢您使用 XMLSchema.xsd 作为 wsimport 参数的提示,我忘记了这一点,它解决了我今天的问题 :)
    【解决方案2】:

    您是如何创建该 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

    【讨论】:

    • 我没有创建 wsdl,很遗憾我无法控制它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    • 1970-01-01
    相关资源
    最近更新 更多