gpt4 book ai didi

java - 未定义元素声明 'xs:schema'

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:09:56 43 4
gpt4 key购买 nike

我对网络服务完全陌生。

我必须为 Web 服务编写其余的 Web 服务客户端。 Web 服务在 SoapUI 上运行良好。 URL 的 WSDL 文件已提供给我。但是当我在我的 Eclipse 项目中添加 wsdl 文件时,它给出了编译错误

src-resolve.4.2: Error resolving component 'xs:schema'. It was detected that 'xs:schema' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'. If this is the incorrect namespace, perhaps the prefix of 'xs:schema' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'.

我在谷歌上搜索了很多以消除这些错误,但没有任何效果。如果我忽略错误并尝试使用 wsimport 和 wsdl2java 命令创建 stub 它给出了错误

[ERROR] undefined element declaration 'xs:schema'
line 1 of http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl

我正在使用下面的命令生成 stub

wsimport -d e:\test -s E:\wssrc http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl -wsdllocation "../../../../../WEB-INF/wsdl/CorpsiteService.svc.wsdl"

我被困在这一点上,一整天都在为此苦苦挣扎。对此的任何帮助都会非常有帮助

最佳答案

解决方案似乎是为 xs:schema 提供替代绑定(bind)如 https://metro.java.net/2.1/guide/Dealing_with_schemas_that_are_not_referenced.html 中所述

具体来说,对于 http://www.w3.org/2001/XMLSchema通常导入到命名空间 xs 中, 还有一些额外的工作需要完成。

命令为:wsimport -b <a href="http://www.w3.org/2001/XMLSchema.xsd" rel="noreferrer noopener nofollow">http://www.w3.org/2001/XMLSchema.xsd</a> -b customization.xjb something.wsdl

从上面链接的 customization.xjb 位于 https://www.java.net//blog/kohsuke/archive/20070228/xsd.xjb或从下面复制

此自定义的存在是为了处理使用模式模式(在多个模式中作为相同 namespace 导入)可能引起的一些命名冲突。

自定义.xjb

<?xml version="1.0" encoding="UTF-8"?>
<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>

我已经尝试使用这些文件和相关的 -b参数到 wsimport并且已经(显然)克服了这个错误(以及其他错误)。也就是说,我不能 100% 确定我的新错误部分不是由此引起的(因此这不是一个完整的答案)。如果没有导致问题的实际 wsdl,人们只能对解决问题(以及下一个问题)进行合理的猜测。

关于java - 未定义元素声明 'xs:schema',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18898261/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com