Fwd: Trick sur les interférences wsimport/wsgen et JAXB

Sylvain RICHET <[email protected]> Wed, 28 Sep 2011 11:07:37 +0200
Newsgroups gmane.comp.java.french.general
Message-ID <CAGn21GLgA+KF0vTXLpoDiXM-OJgXRjBt3qTjSuOJRq80a-zHPQ@mail.gmail.com>
--bcaec520e5a72ef29004adfcb98e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

---------- Message transf=E9r=E9 ----------
De : Sylvain RICHET <[email protected]>
Date : 28 septembre 2011 11:07
Objet : Re: Trick sur les interf=E9rences wsimport/wsgen et JAXB
=C0 : Laurent For=EAt <[email protected]>


Salut Laurent,

Les JAXB Bindings, c'est effectivement de cela dont je parlais quand je
disais que j'allais chercher du c=F4t=E9 Customization JAXB...
;-)

Le 27 septembre 2011 16:18, Laurent For=EAt <[email protected]> a =E9=
crit
:

Excuse j'ai lu en diagonale, mais =E7a me fait penser =E0 du bindings JAXB,=
 qui
> te permet faire co=EFncider un =E9l=E9ment =E0 ta propre classe et squizz=
 celle qui
> t'a =E9t=E9 g=E9n=E9r=E9 automatiquement.
>
> My quarter cent.
>
> Laurent For=EAt
> http://www.devcoop.fr,
> http://laurentforet.org
> IvyBeans Creator
> Membre du JUG Bordeaux
>
>
>
> 2011/9/27 Sylvain RICHET <[email protected]>
>
>> Bonjour =E0 Tous,
>>
>> J'ai un WebService, avec une WSDL qui ne doit plus varier dans sa versio=
n
>> actuelle.
>> ("ne doit plus varier" ? =3D=3D> les signatures de m=E9thodes de ma SEI)
>>
>> Or je viens de prendre conscience que sur une List d'une de mes classes,
>> il fallait que j'ajoute une annotation *@XmlElementWrapper* pour
>> satisfaire un mapping XML =3D=3D> JAVA via JAXB.
>>
>> # Voici la classe annot=E9e JAXB :
>>
>> @XmlRootElement
>> public class DbiLayoutItem {
>>
>>     @XmlElement(required =3D true)
>>     protected String label;
>>
>>     @XmlElementWrapper(name=3D"items")        <=3D=3D ma personnalisatio=
n
>>     @XmlElement(name=3D"dbiLayoutItem")       <=3D=3D "  "
>>     //@XmlElement(name=3D"items")             <=3D=3D version initiale
>>     protected List<DbiLayoutItem> items;
>>
>>     [...]
>> }
>>
>> *# WSIMPORT/WSGEN, qui s'appuie sur JAXB, est sensible aux annotations
>> JAXB.*
>>    Du coup, lors de la g=E9n=E9ration des classes clientes via ces tools=
, une
>> nouvelle inner class "Items" apparait, dans la classe cliente/proxy
>> "DbiLayoutItem" :
>>
>> @XmlAccessorType(XmlAccessType.FIELD)
>> @XmlType(name =3D "dbiLayoutItem", namespace =3D
>> "urn:NETIA:schema:SEARCH_LAYOUT", propOrder =3D {
>>     "label",
>>     "items",
>>     [...]
>> })
>> public class DbiLayoutItem {
>>
>>     @XmlElement(required =3D true)
>>     protected String label;
>>
>>     protected DbiLayoutItem.Items items;            <=3D=3D !
>>     [...]
>>
>>
>>     @XmlAccessorType(XmlAccessType.FIELD)
>>     @XmlType(name =3D "", propOrder =3D {
>>         "dbiLayoutItem"
>>     })
>>     public static class Items {
>>
>>         protected List<DbiLayoutItem> dbiLayoutItem;
>>         [...]
>>     }
>> }
>>
>> *# Ze probl=E8me :*
>> *=E7a vient p=E9ter mon contrat de WSDL, par rapport =E0 ce qu'il y avai=
t
>> auparavant sans l'annotation @XmlElementWrapper.*
>>
>> # D'o=F9 ma question :
>> *comment faire pour =E9viter la g=E9n=E9ration de cette inner class
>> suppl=E9mentaire ?*
>>
>> En effet, je voudrais que WSIMPORT/WSGEN me garde la d=E9finition initia=
le
>> de la liste dans ma classe cliente "DbiLayoutItem" :
>> public class DbiLayoutItem {
>>
>>     @XmlElement(required =3D true)
>>     protected String label;
>>
>>     protected List<DbiLayoutItem> items;            <=3D=3D pas d'inner =
class
>>     [...]
>> }
>>
>>
>> D=E8s =E0 pr=E9sent, je vais fouiller un peu du c=F4t=E9 de la "customis=
ation
>> JAXB"... mais =E7a n'est pas dit du tout que cela soit possible.
>>
>> Si l'un d'entre Vous est interpell=E9 (ou a une id=E9e, ou a =E9t=E9 con=
front=E9 =E0
>> une probl=E8matique similaire)
>> merci d'avance
>>
>>
>>
>

--bcaec520e5a72ef29004adfcb98e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br><div class=3D"gmail_quote">---------- Message transf=E9r=E9 -------=
---<br>De=A0: <b class=3D"gmail_sendername">Sylvain RICHET</b> <span dir=3D=
"ltr">&lt;<a href=3D"mailto:[email protected]">[email protected]</a=
>&gt;</span><br>
Date=A0: 28 septembre 2011 11:07<br>Objet=A0: Re: Trick sur les interf=E9re=
nces wsimport/wsgen et JAXB<br>=C0=A0: Laurent For=EAt &lt;<a href=3D"mailt=
o:[email protected]">[email protected]</a>&gt;<br><br><br>Salut=
 Laurent,<br>
<br>Les JAXB Bindings, c&#39;est effectivement <span style=3D"background-co=
lor:rgb(51, 204, 0)" name=3D"textmarker_13"></span><span style=3D"backgroun=
d-color:rgb(255, 255, 0)" name=3D"textmarker_12"></span>de cela dont je par=
lais quand je disais que j&#39;allais chercher du c=F4t=E9 Customization JA=
XB...<br>

;-)<span style=3D"background-color:rgb(255, 0, 0)" name=3D"textmarker_11"><=
/span><span style=3D"background-color:rgb(51, 204, 0)" name=3D"textmarker_1=
0"></span><span style=3D"background-color:rgb(255, 255, 0)" name=3D"textmar=
ker_9"></span><span style=3D"background-color:rgb(51, 204, 0)" name=3D"text=
marker_8"></span><span style=3D"background-color:rgb(51, 204, 0)" name=3D"t=
extmarker_7"></span><br>

<br><div class=3D"gmail_quote">Le 27 septembre 2011 16:18, Laurent For=EAt =
<span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>&gt;</span> a =E9crit :<div><div></div><=
div class=3D"h5">
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">
Excuse j&#39;ai lu en diagonale, mais =E7a me fait penser =E0 du bindings J=
AXB, qui te=A0permet faire=A0co=EFncider=A0un =E9l=E9ment =E0 ta propre cla=
sse et squizz celle qui t&#39;a =E9t=E9 g=E9n=E9r=E9 automatiquement.<div><=
div><br></div><div>My quarter cent.</div>



<div><br clear=3D"all"><font color=3D"#888888">Laurent For=EAt<br><a href=
=3D"http://www.devcoop.fr" target=3D"_blank">http://www.devcoop.fr</a>, <br=
><a href=3D"http://laurentforet.org" target=3D"_blank">http://laurentforet.=
org</a><br>

IvyBeans Creator<br>Membre du JUG Bordeaux</font><div><div></div><div><br>
<br><br><div class=3D"gmail_quote">2011/9/27 Sylvain RICHET <span dir=3D"lt=
r">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">akamanouc=
[email protected]</a>&gt;</span><br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<span style=3D"font-family:tahoma,sans-serif">Bonjour =E0 Tous,</span><br s=
tyle=3D"font-family:tahoma,sans-serif"><br style=3D"font-family:tahoma,sans=
-serif"><span style=3D"font-family:tahoma,sans-serif">J&#39;ai un WebServic=
e, avec une WSDL qui ne doit plus varier dans sa version actuelle.</span><b=
r style=3D"font-family:tahoma,sans-serif">




<span style=3D"font-family:tahoma,sans-serif">(&quot;ne doit plus varier&qu=
ot; ? =3D=3D&gt; les signatures de m=E9thodes de ma SEI)</span><br style=3D=
"font-family:tahoma,sans-serif"><br style=3D"font-family:tahoma,sans-serif"=
><span style=3D"font-family:tahoma,sans-serif">Or je viens de prendre consc=
ience que sur une List d&#39;une de mes classes, il fallait que j&#39;ajout=
e une annotation <b>@XmlElementWrapper</b> pour satisfaire un mapping XML =
=3D=3D&gt; JAVA via JAXB.</span><br>




<br># Voici la classe annot=E9e JAXB :<br style=3D"font-family:tahoma,sans-=
serif"><br><span style=3D"font-family:courier new,monospace">@XmlRootElemen=
t</span><br style=3D"font-family:courier new,monospace"><span style=3D"font=
-family:courier new,monospace">public class DbiLayoutItem {</span><br style=
=3D"font-family:courier new,monospace">




<br style=3D"font-family:courier new,monospace"><span style=3D"font-family:=
courier new,monospace">=A0=A0=A0 @XmlElement(required =3D true)</span><br s=
tyle=3D"font-family:courier new,monospace"><span style=3D"font-family:couri=
er new,monospace">=A0=A0=A0 protected String label;</span><br style=3D"font=
-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0 =A0</span><br styl=
e=3D"font-family:courier new,monospace"><span style=3D"font-family:courier =
new,monospace">=A0=A0 =A0@XmlElementWrapper(name=3D&quot;items&quot;)=A0=A0=
=A0=A0=A0=A0=A0 &lt;=3D=3D ma personnalisation</span><br style=3D"font-fami=
ly:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0 =A0@XmlElement(nam=
e=3D&quot;dbiLayoutItem&quot;)=A0=A0=A0=A0=A0=A0 &lt;=3D=3D &quot;=A0 &quot=
;</span><br style=3D"font-family:courier new,monospace"><span style=3D"font=
-family:courier new,monospace">=A0=A0 =A0//@XmlElement(name=3D&quot;items&q=
uot;)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 &lt;=3D=3D version initiale</span=
><br style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 protected List&=
lt;DbiLayoutItem&gt; items;</span><br style=3D"font-family:courier new,mono=
space"><span style=3D"font-family:courier new,monospace">=A0=A0 =A0</span><=
br style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0 =A0[...]</span><br=
 style=3D"font-family:courier new,monospace"><span style=3D"font-family:cou=
rier new,monospace">}</span><br><br><b># WSIMPORT/WSGEN, qui s&#39;appuie s=
ur JAXB, est sensible aux annotations JAXB.</b><br>




=A0=A0 Du coup, lors de la g=E9n=E9ration des classes clientes via ces tool=
s, une nouvelle inner class &quot;Items&quot; apparait, dans la classe clie=
nte/proxy &quot;DbiLayoutItem&quot; :<br><br><span style=3D"font-family:cou=
rier new,monospace">@XmlAccessorType(XmlAccessType.FIELD)</span><br style=
=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">@XmlType(name =3D &quot;d=
biLayoutItem&quot;, namespace =3D &quot;urn:NETIA:schema:SEARCH_LAYOUT&quot=
;, propOrder =3D {</span><br style=3D"font-family:courier new,monospace"><s=
pan style=3D"font-family:courier new,monospace">=A0=A0=A0 &quot;label&quot;=
,</span><br style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 &quot;items&quo=
t;,</span><br style=3D"font-family:courier new,monospace"><span style=3D"fo=
nt-family:courier new,monospace">=A0=A0=A0 [...]</span><br style=3D"font-fa=
mily:courier new,monospace">




<span style=3D"font-family:courier new,monospace">})</span><br style=3D"fon=
t-family:courier new,monospace"><span style=3D"font-family:courier new,mono=
space">public class DbiLayoutItem {</span><br style=3D"font-family:courier =
new,monospace">




<br style=3D"font-family:courier new,monospace"><span style=3D"font-family:=
courier new,monospace">=A0=A0=A0 @XmlElement(required =3D true)</span><br s=
tyle=3D"font-family:courier new,monospace"><span style=3D"font-family:couri=
er new,monospace">=A0=A0=A0 protected String label;</span><br style=3D"font=
-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 </span><br styl=
e=3D"font-family:courier new,monospace"><span style=3D"font-family:courier =
new,monospace">=A0=A0=A0 protected DbiLayoutItem.Items items;=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 &lt;=3D=3D !</span><br style=3D"font-family:courier n=
ew,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 [...]</span><br=
 style=3D"font-family:courier new,monospace"><br style=3D"font-family:couri=
er new,monospace"><span style=3D"font-family:courier new,monospace">=A0=A0=
=A0 </span><br style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 @XmlAccessorTyp=
e(XmlAccessType.FIELD)</span><br style=3D"font-family:courier new,monospace=
"><span style=3D"font-family:courier new,monospace">=A0=A0=A0 @XmlType(name=
 =3D &quot;&quot;, propOrder =3D {</span><br style=3D"font-family:courier n=
ew,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0=A0=A0 &qu=
ot;dbiLayoutItem&quot;</span><br style=3D"font-family:courier new,monospace=
"><span style=3D"font-family:courier new,monospace">=A0=A0=A0 })</span><br =
style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 public static c=
lass Items {</span><br style=3D"font-family:courier new,monospace"><br styl=
e=3D"font-family:courier new,monospace"><span style=3D"font-family:courier =
new,monospace">=A0=A0=A0=A0=A0=A0=A0 protected List&lt;DbiLayoutItem&gt; db=
iLayoutItem;</span><br style=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 =A0=A0=A0 [...]=
</span><br style=3D"font-family:courier new,monospace"><span style=3D"font-=
family:courier new,monospace">=A0=A0=A0 }</span><br style=3D"font-family:co=
urier new,monospace">




<span style=3D"font-family:courier new,monospace">}</span><br><br><i><b># Z=
e probl=E8me :</b></i><br><i>=E7a vient p=E9ter mon contrat de WSDL, par ra=
pport =E0 ce qu&#39;il y avait auparavant sans l&#39;annotation @XmlElement=
Wrapper.</i><br>




=A0=A0=A0 <br># D&#39;o=F9 ma question :<br><i>comment faire pour =E9viter =
la g=E9n=E9ration de cette inner class suppl=E9mentaire ?</i><br><br>En eff=
et, je voudrais que WSIMPORT/WSGEN me garde la d=E9finition initiale de la =
liste dans ma classe cliente &quot;DbiLayoutItem&quot; :<br>




<span style=3D"font-family:courier new,monospace">public class DbiLayoutIte=
m {</span><br style=3D"font-family:courier new,monospace"><br style=3D"font=
-family:courier new,monospace"><span style=3D"font-family:courier new,monos=
pace">=A0=A0=A0 @XmlElement(required =3D true)</span><br style=3D"font-fami=
ly:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 protected Strin=
g label;</span><br style=3D"font-family:courier new,monospace"><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0 </span><br style=3D"font-f=
amily:courier new,monospace">




<span style=3D"font-family:courier new,monospace">=A0=A0=A0 protected List&=
lt;DbiLayoutItem&gt; items;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 &lt;=3D=3D pas=
 d&#39;inner class</span><br style=3D"font-family:courier new,monospace"><s=
pan style=3D"font-family:courier new,monospace">=A0=A0=A0 [...]</span><br s=
tyle=3D"font-family:courier new,monospace">




<span style=3D"font-family:courier new,monospace">}</span><br><br><br>D=E8s=
 =E0 pr=E9sent, je vais fouiller un peu du c=F4t=E9 de la &quot;customisati=
on JAXB&quot;... mais =E7a n&#39;est pas dit du tout que cela soit possible=
.<br><br>




Si l&#39;un d&#39;entre Vous est interpell=E9 (ou a une id=E9e, ou a =E9t=
=E9 confront=E9 =E0 une probl=E8matique similaire)<br>merci d&#39;avance<br=
><br><br>
</blockquote></div><br></div></div></div></div>
</blockquote></div></div></div><br>
</div><br>

--bcaec520e5a72ef29004adfcb98e--