JAX-WS: Comstackr Schema distinct de WSDL

Si vous avez un schéma assez volumineux utilisé dans plusieurs services Web, je souhaite donc séparer la compilation XSD de la compilation WSDL. Dans un exemple simplifié, la compilation en une seule étape fonctionne:

$ wsimport -verbose service.wsdl parsing WSDL... Generating code... org/example/wsdl/mysvc/MySvcPortType.java org/example/wsdl/mysvc/MySvcService.java org/example/ns1/Element1.java org/example/ns1/ObjectFactory.java org/example/ns1/package-info.java ... 

Comstackr le fichier xsd et utiliser le fichier d’épisode résultant ne fonctionne pas:

 $ wsimport -b schema3.episode service.wsdl parsing WSDL... [ERROR] Schema descriptor {http://www.example.org/ns1}element1 in message part "part1" is not defined and could not be bound to Java. Perhaps the schema descriptor {http://www.example.org/ns1}element1 is not defined in the schema imported/included in the WSDL. You can either add such imports/includes or run wsimport and provide the schema location using -b switch. line 9 of file:...jaxepisode_element/service.wsdl 

Alors, comment puis-je utiliser le schéma précompilé dans wsimport?

Addendum: L’utilisation de l’épisode lors de l’inclusion dans un autre schéma fonctionne et évite les nouvelles compilations (d3.jar contient les classes genréées de schema3 + schema3.episode sous la forme META-INF / sun-jaxb.episode):

 $ xjc schema4.xsd d3.jar -extension parsing a schema... compiling a schema... org/example/ns2/Element2.java org/example/ns2/ObjectFactory.java org/example/ns2/package-info.java 

Sans le package précompilé:

 $ xjc schema4.xsd -extension parsing a schema... compiling a schema... org/example/ns1/Element1.java org/example/ns1/ObjectFactory.java org/example/ns1/package-info.java org/example/ns2/Element2.java org/example/ns2/ObjectFactory.java org/example/ns2/package-info.java 

WSDL:

                                     

schema3.xsd:

          

schema4.xsd:

           

Le fichier d’épisode généré:

            

Vous pouvez utiliser maven, séparé pour chacun et généré avec Apache CXF.

J’ai un exemple qui peut vous aider.

Propriétés:

   3.0.4 3.0.4 3.0.3  

dépendances:

    org.apache.cxf cxf-rt-frontend-jaxws ${apache.cxf.version}   org.apache.cxf cxf-rt-transports-http ${apache.cxf.version}   org.apache.cxf cxf-rt-databinding-jaxb ${apache.cxf.version}   com.sun.xml.bind jaxb-core   com.sun.xml.bind jaxb-impl   xalan xalan     

Exécuter -> mvn clean install -Pgenerates-nfe-services

   generates-nfe-services   generates-nfe-services      org.apache.cxf cxf-codegen-plugin   generate-sources generate-sources   ${basedir}/src/main/java   -validate -client -verbose -xjc-npa -xjc-verbose -xjc-extension -exsh true -keep      ${basedir}/src/main/wsdl/br/gov/rs/sefaz/nfe/homologacao/NfeConsultaCadastro.wsdl   -p br.gov.rs.sefaz.nfe.consulta.cadastro      wsdl2java        

Exécuter -> mvn clean install -Pgenerates-layouts-nfe

   generates-layouts-nfe   generates-layouts-nfe      org.apache.cxf cxf-xjc-plugin ${cxf-xjc-plugin.version}   generate-sources generate-sources  xsdtojava    ${basedir}/src/main/java   ${basedir}/src/main/schemas/nfe/PL_008f/leiauteConsSitNFe_v3.10.xsd  br.inf.portalfiscal.nfe.v310.leiaute.consulta.situacao.nfe  true   -extension           

Vous pouvez créer un projet maven pour ne générer que le wsdl et un autre pour ne générer que le xsd.

REMARQUE:

Si son projet ne nécessite pas l’utilisation du WSDL, passez à json-rest-api.

Utilisez REST et soyez heureux. \ o /

J’espère que ça aide.