java - 使用 Jax 生成 Proxy Web 服务客户端时出错

标签 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 的新手,所以非常感谢任何帮助。

谢谢

最佳答案

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

关于java - 使用 Jax 生成 Proxy Web 服务客户端时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6209583/

相关文章:

python - 如何从iOS应用程序调用Python的ladon框架开发的Web服务?

java - 在 Android 上使用 KSOAP2 发送 SOAP 消息

Java 1.6 Maven 项目与 Tomcat Liferay 6.2 GA6 的 SOAP XML JAX-WS (WAS Portal 7) 服务无法访问端点

java - 如何将身份验证 header 传递给 JAXWS SOAP 客户端

java - 替换 2D char* 数组中的字符串值 c/java jni

java - 注释掉 "@Override"是否安全?

java - 在滑动选项卡布局中停留在同一选项卡中时切换到不同的 fragment

java - 在 Mac 上为我的 Java 7 应用程序创建包安装

c# - 描述 ASMX 网络服务 WebMethod 参数

maven - CXF InInterceptor 未触发