2011-11-29 22 views
9

Ho il seguente tipo di dati definito in un wsdl:cambiamento pacchetto di generato classe JAXB

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions name="myService" targetNamespace="http://example.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> 
    <wsdl:types> 
     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="example.com" targetNamespace="example.com" version="1.0"> 
      <xs:simpleType name="MyEnum"> 
       <xs:restriction base="xs:string"> 
        <xs:enumeration value="one"/> 
        <xs:enumeration value="two"/> 
       </xs:restriction> 
      </xs:simpleType> 
      <!-- SNIP other data types --> 
     </xs:schema> 
    </wsdl:types> 
</wsdl:definitions> 

voglio MyEnum a cadere in un suo pacchetto. Così, ho usato un jaxws file di collegamento, e utilizzato XPath per attraversare le associazioni dello schema e JAXB per impostare il pacchetto, come segue:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<jaxws:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://java.sun.com/xml/ns/jaxws"> 
    <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='example.com']"> 
     <jxb:schemaBindings> 
      <jxb:package name="abra.ca.dabra" /> <!-- this works, and changes package of all classes in the namespace--> 
     </jxb:schemaBindings> 
     <jxb:bindings node="//xs:simpleType[@name='MyEnum']"> 
      <jxb:package name="a.b.c"/> <!-- this does not work --> 
     </jxb:bindings> 
    </jaxws:bindings> 
    <!-- SNIP - other functional jaxws bindings --> 
</jaxws:bindings> 

Ora, il percorso impostato in schemaBindings prende - e mette tutti i tipi di dati da quella schema/targetnamespace nel pacchetto abra.ca.dabra. Tuttavia, non riesco a impostare il pacchetto di solo MyEnum - che è quello che voglio.

Uso il file wsdl2java di cxf per fornire il file di bind. Mi sto perdendo qualcosa?

+0

ho incontrato lo stesso problema. Hai risolto il tuo? – Rudy

+0

Il file di bind non è corretto: il prefisso dello spazio dei nomi 'jaxws' non è associato ad alcun namespace. – whaefelinger

+0

Simile, il prefisso 'xs' non è associato. – whaefelinger

risposta

0

Si è tentato di aggiungere un secondo schema al WSDL che contiene solo MyEnum, con un diverso spazio dei nomi? La definizione dello schema originale dovrebbe quindi importare quel tipo dal nuovo spazio dei nomi.

2

vorrei provare con qualcosa di ComeQuesta:

<jaxws:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"> 

<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle> 

<!-- set default package structure --> 
<jaxws:package name="abra.ca.dabra" /> 

<!-- set package structure for complex schema types --> 
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:simpleType[@name='MyEnum']"> 
    <jaxb:schemaBindings> 
     <jaxb:package name="a.b.c" /> 
    </jaxb:schemaBindings> 
</jaxws:bindings> 

Per essere più precisi si dovrebbe fare tutto il WSDL disponibile

Spero che questo aiuti ...

Problemi correlati