Bonjour, je me permet de vous sollicitez car j'ai une exception lors de l'appel d'un web service qui renvois un type complexe.
Voila le type complexe en question.
Ensuite mon WS.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package data; public class User implements java.io.Serializable { private String login; private String password; public User() { } public User(String login, String password) { this.login = login; this.password = password; } public String getLogin() { return this.login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } }
Mon deploy.wsdd.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 package ws; import data.User; public class MyWS { public User getUser() { return new User("login", "password"); } }
Ma définition wsdl.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <service name="MyWS" provider="java:RPC" style="rpc" use="literal"> <parameter name="wsdlTargetNamespace" value="http://www.my-ws.com"/> <parameter name="wsdlServiceElement" value="MyWSService"/> <parameter name="schemaUnqualified" value="http://xml.apache.org/xml-soap"/> <parameter name="wsdlServicePort" value="MyWSPort"/> <parameter name="wsdlPortType" value="MyWSPortType"/> <parameter name="scope" value="session"/> <parameter name="className" value="ws.MyWS"/> <parameter name="typeMappingVersion" value="1.1"/> <operation name="getUser" qname="operNS:getUser" xmlns:operNS="http://www.my-ws.com" returnQName="getUserReturn" returnType="rtns:User" xmlns:rtns="http://www.my-ws.com" returnItemQName="item" soapAction="" > </operation> <parameter name="allowedMethods" value="getUser"/> <typeMapping xmlns:ns="http://www.my-ws.com" qname="ns:User" type="data.User" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </service>
Mon client du WS.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://www.my-ws.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://www.my-ws.com" xmlns:intf="http://www.my-ws.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:types> <schema targetNamespace="http://www.my-ws.com" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="User"> <sequence> <element name="login" nillable="true" type="xsd:string"/> <element name="password" nillable="true" type="xsd:string"/> </sequence> </complexType> </schema> </wsdl:types> <wsdl:message name="getUserResponse"> <wsdl:part name="getUserReturn" type="impl:User"/> </wsdl:message> <wsdl:message name="getUserRequest"> </wsdl:message> <wsdl:portType name="MyWSPortType"> <wsdl:operation name="getUser"> <wsdl:input message="impl:getUserRequest" name="getUserRequest"/> <wsdl:output message="impl:getUserResponse" name="getUserResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="MyWSPortSoapBinding" type="impl:MyWSPortType"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getUser"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getUserRequest"> <wsdlsoap:body namespace="http://www.my-ws.com" use="literal"/> </wsdl:input> <wsdl:output name="getUserResponse"> <wsdlsoap:body namespace="http://www.my-ws.com" use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="MyWSService"> <wsdl:port binding="impl:MyWSPortSoapBinding" name="MyWSPort"> <wsdlsoap:address location="http://localhost:8080/MyWebApp/ws/MyWS"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Et j'obtiens l'exception suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package ws; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import com.my_ws.www.MyWSPortType; import com.my_ws.www.MyWSService; import com.my_ws.www.MyWSServiceLocator; import com.my_ws.www.User; public class ClientWS { public static void main(String[] args) { MyWSService service = new MyWSServiceLocator(); try { MyWSPortType port = service.getMyWSPort(); User user; try { user = port.getUser(); } catch(RemoteException ex) { ex.printStackTrace(); } } catch(ServiceException ex) { ex.printStackTrace(); } } }
J'ai essayé de retourné des types non complexe et cela fonctionne bien.AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.IllegalArgumentException: "setAttribute": attribut non sérialisable
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:My-PC
java.lang.IllegalArgumentException: "setAttribute": attribut non sérialisable
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.my_ws.http://www.MyWSPortSoapBindingStub.g...gStub.java:155)
at ws.ClientWS.main(ClientWS.java:24)
Donc je me tourne vers vous si quelqu'un a une idée, elle serait la bienvenue.
Merci.
Partager