IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Java Discussion :

WebService et retour d'un Object "complexe"


Sujet :

Services Web Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de hadler
    Inscrit en
    Décembre 2004
    Messages
    91
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Décembre 2004
    Messages : 91
    Par défaut WebService et retour d'un Object "complexe"
    Bonjour,

    Je me lance depuis peu de temps dans les WebServices avec JBuilder, et je rencontre quelques problèmes.

    Le dernier en date, réussir à renvoyer un Objet de ma création. Essai après essai, c'est le même message d'erreur qui se reproduit :
    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
    05-oct.-2009 15:13:42 org.apache.axis.client.Call invoke
    GRAVE: Exception:
    org.xml.sax.SAXException: Deserializing parameter 'getDocReturn':  could not find deserializer for type {http://business}WsResponse
    	at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
    	at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    	at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    	at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    	at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    	at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    	at org.apache.axis.client.Call.invoke(Call.java:2467)
    	at org.apache.axis.client.Call.invoke(Call.java:2366)
    	at org.apache.axis.client.Call.invoke(Call.java:1812)
    	at org.apache.axis.client.Call.invoke(Call.java:1727)
    	at be.fgov.minfin.drmc.WebService.execute(WebService.java:33)
    	at be.fgov.minfin.drmc.Main.testWS2(Main.java:151)
    	at be.fgov.minfin.drmc.Main.main(Main.java:23)
    AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode: 
     faultString: org.xml.sax.SAXException: Deserializing parameter 'getDocReturn':  could not find deserializer for type {http://business}WsResponse
     faultActor: 
     faultNode: 
     faultDetail: 
    	{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Deserializing parameter 'getDocReturn':  could not find deserializer for type {http://business}WsResponse
    	at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
    	at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    	at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    	at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    	at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    	at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    	at org.apache.axis.client.Call.invoke(Call.java:2467)
    	at org.apache.axis.client.Call.invoke(Call.java:2366)
    	at org.apache.axis.client.Call.invoke(Call.java:1812)
    	at org.apache.axis.client.Call.invoke(Call.java:1727)
    	at be.fgov.minfin.drmc.WebService.execute(WebService.java:33)
    	at be.fgov.minfin.drmc.Main.testWS2(Main.java:151)
    	at be.fgov.minfin.drmc.Main.main(Main.java:23)
     
    	{http://xml.apache.org/axis/}hostname:CZC7180S54

    Voici le code de mon WebService :
    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
    public class Accessor {
     
    	public HashMap<String, Object> getDocument (String projectName) {
    		HashMap <String, Object> map = new HashMap<String, Object>() ;
    		map.put("status", "0") ;
    		map.put("projectName", projectName) ;
    		map.put("document", "new document") ;
    		return map ;
    	}
     
    	public WsResponse getDoc (String projectName) {
    		WsResponse wr = new WsResponse ("0", projectName) ;
    		return wr ;
    	}
    }

    Le contenu de la classe que je souhaite renvoyer
    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
    public class WsResponse implements Serializable {
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	String status ;
    	String projectName ;
     
    	public WsResponse () {
     
    	}
     
    	public WsResponse (String status, String name) {
    		this.status = status ; 
    		this.projectName = name ;
    	}
     
    	public String getProjectName() {
    		return projectName;
    	}
     
    	public void setProjectName(String projectName) {
    		this.projectName = projectName;
    	}
     
    	public String getStatus() {
    		return status;
    	}
     
    	public void setStatus(String status) {
    		this.status = status;
    	}
     
     
    }
    Rien de bien compliqué pour le moment, la base au niveau du webservice et de ce qui est renvoyé.

    J'ai déjà eu du mal à réussir à utiliser les HashMap comme type de retour du WebService à cause de JBuilder, mais ce problème ci me semble insurmontable.
    J'ai beau regardé sur le net, je n'ai pas vu le début d'une solution.

    Ha oui, voici aussi mon WSDL et mon appel client en java.
    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
    75
    76
    77
    78
    79
    80
    81
    82
    83
     <?xml version="1.0" encoding="UTF-8" ?> 
    - <wsdl:definitions targetNamespace="http://services" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://services" xmlns:intf="http://services" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://business" 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://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema">
      <import namespace="http://business" /> 
      <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> 
    - <complexType name="mapItem">
    - <sequence>
      <element name="key" nillable="true" type="xsd:anyType" /> 
      <element name="value" nillable="true" type="xsd:anyType" /> 
      </sequence>
      </complexType>
    - <complexType name="Map">
    - <sequence>
      <element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem" /> 
      </sequence>
      </complexType>
      </schema>
    - <schema targetNamespace="http://business" xmlns="http://www.w3.org/2001/XMLSchema">
      <import namespace="http://xml.apache.org/xml-soap" /> 
      <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> 
    - <complexType name="WsResponse">
    - <sequence>
      <element name="projectName" nillable="true" type="xsd:string" /> 
      <element name="status" nillable="true" type="xsd:string" /> 
      </sequence>
      </complexType>
      </schema>
      </wsdl:types>
    - <wsdl:message name="getDocumentResponse">
      <wsdl:part name="getDocumentReturn" type="apachesoap:Map" /> 
      </wsdl:message>
    - <wsdl:message name="getDocumentRequest">
      <wsdl:part name="projectName" type="xsd:string" /> 
      </wsdl:message>
    - <wsdl:message name="getDocRequest">
      <wsdl:part name="projectName" type="xsd:string" /> 
      </wsdl:message>
    - <wsdl:message name="getDocResponse">
      <wsdl:part name="getDocReturn" type="tns1:WsResponse" /> 
      </wsdl:message>
    - <wsdl:portType name="Accessor">
    - <wsdl:operation name="getDocument" parameterOrder="projectName">
      <wsdl:input message="impl:getDocumentRequest" name="getDocumentRequest" /> 
      <wsdl:output message="impl:getDocumentResponse" name="getDocumentResponse" /> 
      </wsdl:operation>
    - <wsdl:operation name="getDoc" parameterOrder="projectName">
      <wsdl:input message="impl:getDocRequest" name="getDocRequest" /> 
      <wsdl:output message="impl:getDocResponse" name="getDocResponse" /> 
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="AccessorPortSoapBinding" type="impl:Accessor">
      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
    - <wsdl:operation name="getDocument">
      <wsdlsoap:operation soapAction="" /> 
    - <wsdl:input name="getDocumentRequest">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services" use="encoded" /> 
      </wsdl:input>
    - <wsdl:output name="getDocumentResponse">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services" use="encoded" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="getDoc">
      <wsdlsoap:operation soapAction="" /> 
    - <wsdl:input name="getDocRequest">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services" use="encoded" /> 
      </wsdl:input>
    - <wsdl:output name="getDocResponse">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services" use="encoded" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="AccessorService">
    - <wsdl:port binding="impl:AccessorPortSoapBinding" name="AccessorPort">
      <wsdlsoap:address location="http://localhost:8080/TestWs/services/AccessorPort" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>

    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
    		wsdlName = "wsdl" ;
    			wsdlUrl = "http://localhost:8080/TestWs/services/AccessorPort?wsdl" ;
    			WebService ws = new WebService(wsdlUrl, wsdlName) ;
     
    			//TEST METHOD #1 FROM WEBSERVICE 
    			String projectName = "MyProject";
    			wsMethodName = "getDocument" ;
    			parameters = new Object[] {projectName} ;
    			response =  ws.execute(wsMethodName, parameters) ;
    			System.out.println(response);
     
    			//TEST METHOD #2 FROM WEBSERVICE 
    			wsMethodName = "getDoc" ;
    			parameters = new Object[] {projectName} ;
    			response =  ws.execute(wsMethodName, parameters) ;
    			System.out.println(response);

    Si quelqu'un a la moindre idée, je suis preneur.

    Merci d'avance.

  2. #2
    Membre averti
    Inscrit en
    Février 2010
    Messages
    17
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 17
    Par défaut
    Salut,

    Je veux faire un webservice qui permet l affichage et la mise a jour des paramètres qui se trouvent dans une base de données.
    J utilise le netbeans.

    STP si t´as des codes sources ou des docs concernant ce sujet,est ce que tu peux me tenir au courant ?

Discussions similaires

  1. Webservice et retour de Dataset
    Par mike49 dans le forum Services Web
    Réponses: 0
    Dernier message: 06/01/2010, 08h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo