[Axis 2.1.3] Exception : Unexpected subelement
Bonjour,
Je suis en train de réaliser des services Web avec Axis 2 et j'ai un soucis lors de l'exécution du client.
Mon service web retourne un objet de type Résultat qui hérite de RésultatGlobal
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
public class Resultat extends ResultatGlobal{
private Point [] pt;
public Resultat() {
}
public void setPt(Point [] pt) {
this.pt = pt;
}
public Point [] getPt() {
return pt;
}
}
public class ResultatGlobal {
private int nbResult;
private int code;
public ResultatGlobal() {
// TODO Auto-generated constructor stub
}
public void setNbResult(int nbResult) {
this.nbResult = nbResult;
}
public int getNbResult() {
return nbResult;
}
public void setCode(int code) {
this.code = code;
}
public int getCode() {
return code;
}
} |
Le service :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
public class Service {
public Resultat service (int a)
{
Point[] tab = new Point[10];
tab[0] = new Point (1,2);
tab[1] = new Point (1,1);
tab[2] = new Point (2,1);
Resultat r = new Resultat ();
r.setPt(tab);
r.setNbResult(tab.length);
r.setCode(1);
return r;
}
} |
J'ai généré les stub du client avec WSDL2Java et voici la classe main :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
public class Clien {
public static void main(String[] args) throws RemoteException {
MyServiceStub stub =null;
try {
stub = new MyServiceStub("http://localhost:8080/axis2/services/MyService");
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(60 *1000);
//stub = new WebContractHelpdeskStub();
} catch (AxisFault e) { e.printStackTrace(); }
stub.service(0);
}
} |
Voici l'erreur que j'obtiens :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
Exception in thread "main" org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement code
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
at org.apache.ws.axis2.MyServiceStub.fromOM(MyServiceStub.java:3291)
at org.apache.ws.axis2.MyServiceStub.service(MyServiceStub.java:180)
at org.apache.ws.axis2.Clien.main(Clien.java:21)
Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException: Unexpected subelement code
at org.apache.ws.axis2.MyServiceStub$Resultat$Factory.parse(MyServiceStub.java:2249)
at org.apache.ws.axis2.MyServiceStub$ServiceResponse$Factory.parse(MyServiceStub.java:2687)
at org.apache.ws.axis2.MyServiceStub.fromOM(MyServiceStub.java:3285)
... 2 more
Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement code
at org.apache.ws.axis2.MyServiceStub$Resultat$Factory.parse(MyServiceStub.java:2243)
... 4 more |
voici le xml de la réponse qui me semble bon :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:serviceResponse xmlns:ns="http://ws.apache.org/axis2">
<ns:return xmlns:ax21="http://ws.apache.org/axis2/xsd" type="Resultat"><ax21:pt type="Point" />
<ax21:pt type="Point" />
<ax21:pt type="Point" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:pt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:code>1</ax21:code>
<ax21:nbResult>10</ax21:nbResult>
</ns:return></ns:serviceResponse></soapenv:Body></soapenv:Envelope> |
Avez-vous une idée? est-ce que ce genre résultat avec un héritage fonctionne en axis 2 ? en tout cas avec avec Axis 1 ça fonctionnait.
Merci.