Undefined Declare an element 'xs: schema'

I am completely new to web service.

I need to write a leisure web service client for a web service. The web service works great on SoapUI. The WSDL file for the URL is provided to me. But when I add the wsdl file to the Eclipse project, it gives a compilation error

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'. 

I searched a lot to get rid of this error, but nothing worked. If I ignore the errors and try to create stubs using the wsimport commands, as well as the wsdl2java commands, it gives an error

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

I use the command below to create stubs

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

I was stuck at this point and struggled to do this all day. Any help in this regard would be really helpful.

+6
source share
2 answers

The solution for this is similar to alternative bindings for xs:schema , as described in https://metro.java.net/2.1/guide/Dealing_with_schemas_that_are_not_referenced.html

In particular, for http://www.w3.org/2001/XMLSchema , which is often imported into the xs namespace, there is some additional work that needs to be done.

The command will be: wsimport -b http://www.w3.org/2001/XMLSchema.xsd -b customization.xjb something.wsdl

customization.xjb associated with the above is located at https://www.java.net//blog/kohsuke/archive/20070228/xsd.xjb or copied from below

This setting exists to handle some name conflicts that may result from using a schema schema (which is imported as the same namespace in multiple schemas).

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> 

I tried this with these files and the associated -b options with wsimport and got (apparently) minus this error (and to others). However, I am not 100% sure that my new errors are not partially caused by this (and therefore, this will not be the complete answer). Without the actual wsdl causing the problem, one can only reasonably guess how to solve the problem (and the next one).

+7
source

I ran into the same problem solved by adding one line to the Maven plugin

  <args> <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg> </args> 

My Maven plugin is below

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <id>periodictableaccessws</id> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory> <args> <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg> </args> <wsdlFiles> <wsdlFile>doosdaas.wsdl</wsdlFile> </wsdlFiles> <packageName>com.dss.doosdaas</packageName> <vmArgs> <vmArg>-Djavax.xml.accessExternalDTD=all</vmArg> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> </vmArgs> <!-- <bindingDirectory>${basedir}/src/main/resources/jaxb</bindingDirectory> <bindingFiles> <bindingFile>jaxb_binding.xjb</bindingFile> </bindingFiles>--> </configuration> </execution> </executions> </plugin> 
0
source

All Articles