Re: Trick sur les interférences wsimport/wsgen et J AXB

Laurent Forêt <[email protected]> Tue, 27 Sep 2011 16:18:24 +0200
Newsgroups gmane.comp.java.french.general
Message-ID <CAGbcYLkimjzo9Pq+mpfcD5jvcz9r3615Vmx0vAh47avo4byRaw@mail.gmail.com>
--20cf307f3af8fd599e04adecf33d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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 c=
elle 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 version
> 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 personnalisation
>     @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 avait
> 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 initial=
e 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 c=
lass
>     [...]
> }
>
>
> D=E8s =E0 pr=E9sent, je vais fouiller un peu du c=F4t=E9 de la "customisa=
tion
> 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 conf=
ront=E9 =E0
> une probl=E8matique similaire)
> merci d'avance
>
>
>

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

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">Laurent For=EAt<br><a href=3D"http://www.devcoop.fr"=
>http://www.devcoop.fr</a>, <br><a href=3D"http://laurentforet.org">http://=
laurentforet.org</a><br>IvyBeans Creator<br>Membre du JUG Bordeaux<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]">[email protected]</a>&g=
t;</span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-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>

--20cf307f3af8fd599e04adecf33d--