未定义的元素声明'xs:schema'

A N*_*kar 7 java wsdl web-services wsdl2java wsimport

我是网络服务的新手.

我必须为Web服务编写rest 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'.
Run Code Online (Sandbox Code Playgroud)

我搜索了很多东西以摆脱这些错误,但没有任何效果.如果我忽略错误并尝试使用wsimport和wsdl2java命令创建存根,则会出错

[ERROR] undefined element declaration 'xs:schema'
line 1 of http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl
Run Code Online (Sandbox Code Playgroud)

我使用下面的命令来生成存根

wsimport -d e:\test -s E:\wssrc http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl -wsdllocation "../../../../../WEB-INF/wsdl/CorpsiteService.svc.wsdl"
Run Code Online (Sandbox Code Playgroud)

我在这一点上陷入困​​境,并且整天都在努力.任何有关这方面的帮助都会非常有帮助

小智 7

对此的解决方案似乎是提供替代绑定,xs:schemahttps://metro.java.net/2.1/guide/Dealing_with_schemas_that_are_not_referenced.html中所述

具体而言,对于经常导入命名空间的http://www.w3.org/2001/XMLSchemaxs,还需要完成一些额外的工作.

命令是: wsimport -b http://www.w3.org/2001/XMLSchema.xsd -b customization.xjb something.wsdl

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

此自定义用于处理可能因使用架构架构(在多个架构中作为同一名称空间导入)而产生的某些命名冲突.

customization.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>
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这些文件和相关-b参数,wsimport并且已经(显然)已经过了这个错误(以及其他的错误).也就是说,我并不是100%肯定我的新错误不是由此造成的(因此这不是一个完整的答案).如果没有实际的wsdl导致问题,人们只能对解决问题(以及下一个问题)采取合理的猜测.