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

Spring Java Discussion :

Appel de WebServices ! [Web Services]


Sujet :

Spring Java

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 163
    Points : 143
    Points
    143
    Par défaut Appel de WebServices !
    Quelqu'un a t-il des "bonnes adresses" pour savoir comment appeler un WebService à l'aide de Spring ?
    J'aimerai savoir de quoi Spring a besoin pour faire cet appel ?

    Merci.

  2. #2
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Points : 6 301
    Points
    6 301

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 163
    Points : 143
    Points
    143
    Par défaut J'ai bien lue la doc Spring !
    mais j'ai quelques questions !
    - Je ne vois pas où on met le nom du fichier xml utilisé pour la configuration de Spring, dans l'application ?
    - L'appel au web service me semble un peu trop magique
    - Mon Web Service n'est pas instancier ! le faire et comment ?

    Du coup, au lancement, j'ai un super nullPointerException !!

    Mon code :
    - fichier de conf Spring :
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
       "http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
    <bean id="consultWebService"
    	class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    	<property name="serviceInterface">
    		<value>com.socgen.bva.cdn.consultationimagevaleur.ConsultationImageValeur</value>
    	</property>
    	<property name="portInterface">
    		<value>com.socgen.bva.cdn.consultationimagevaleur.ConsultationImageValeur.RemoteConsultationImageValeur</value>
    	</property>
    	<property name="wsdlDocumentUrl">
    		<value>
    			https://...consultationImageValeurCDN.wsdl
    		</value>
    	</property>
    	<property name="namespaceUri">
    		<value>
    			http://www.socgen.com/wsdl/ConsultationImageValeur/
    		</value>
    	</property>
    	<property name="serviceName">
    		<value>ConsultationImageValeur</value>
    	</property>
    	<property name="portName">
    		<value>IConsultationImageValeur</value>
    	</property>
    </bean>
    <bean id="client" class="com.socgen.bva.cdn.consultationimagevaleur.ConsultationImageValeur">
    	<property name="service">
    		<ref bean="consultWebService" />
    	</property>
    </bean>
    </beans>
    - L'appli :
    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
     //imports...
    public class TestAppli {
     
    	public TestAppli() {
    	}
     
    	ConsultationImageValeur service ; //nom de mon WebService
     
    	/**
             * @param args
             * @throws GenericException 
             */
    	public static void main(String[] args) throws GenericException {
    		System.out.println("bonjour");
    		String res = maMethode();
    		System.out.println(res);
    	}
     
    	public void setService(ConsultationImageValeur service) {
    		this.service = service;
    	}
     
    	public static String maMethode() throws GenericException {
    		TestAppli ta = new TestAppli();
    		DataIn1 param = ta.init();
    		DataOut1 sortie = ta.serv(param);
    		return ta.transform(sortie);
    	}
     
    	public DataIn1 init() {
    		DataIn1 param = new DataIn1();
    		return param;
    	}
     
    	public DataOut1 serv(DataIn1 param) throws GenericException {
    		DataOut1 sortie = service.getValeur(param);
    		return sortie;
    	}
     
    	public String transform(DataOut1 sortie) {
    		String aff = sortie.getActif().getCodeIsin();
    		return aff ;
    	}
    }

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 163
    Points : 143
    Points
    143
    Par défaut J'ai tenté :
    J'ai donc voulu instancier mon Web Service -> nullPointer

    this.service = (ConsultationImageValeur) getWebApplicationContext().getBean("consultWebService");

    il va chercher cette méthode dans Spring ->
    public class TestAppli extends ServletEndpointSupport{

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 163
    Points : 143
    Points
    143
    Par défaut
    Mon fichier de conf :
    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
    <beans>
     
    <bean id="consultWebService"
    	class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    	<property name="serviceInterface">
    		<value>com.socgen.bva.cdn.consultationimagevaleur.IConsultationImageValeur</value>
    	</property>
    	<!-- <property name="portInterface">
    		<value>com.socgen.bva.cdn.consultationimagevaleur.ConsultationImageValeur.RemoteConsultationImageValeur</value>
    	</property> -->
    	<property name="wsdlDocumentUrl">
    		<value>
    			http://.../consultationImageValeurCDN.wsdl
    		</value>
    	</property>
    	<property name="namespaceUri">
    		<value>
    			http://..../ConsultationImageValeur/
    		</value>
    	</property>
    	<property name="serviceName">
    		<value>ConsultationImageValeur</value>
    	</property>
    	<property name="portName">
    		<value>IConsultationImageValeur</value>
    	</property>
    	<property name="username">
    		<value>...</value>
    	</property>
    	<property name="password">
    		<value>...</value>
    	</property>
    </bean>
     
    <bean id="client" class="com.socgen.bva.consultationimagevaleur.ConsultationImageValeur">
    	<property name="service">
    		<ref bean="consultWebService"/>
    	</property>
    </bean>
    </beans>
    L'appli :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    try {
     
    		BeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/ApplicationContext.xml"));
        	service=(ConsultationImageValeur)factory.getBean("client");
     
    			sortie = service.getValeur(param);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Pb Appel à un WebService sécurisé - tomcat + netbeans + metro
    Par Saitou-San dans le forum Services Web
    Réponses: 6
    Dernier message: 29/04/2008, 07h55
  2. Appeler un WebService depuis une procédure stockée
    Par kheironn dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 18/11/2007, 12h10
  3. Comment appeller un webservice ?
    Par fraginfo dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 12/12/2006, 16h23
  4. [VB5] appeler un webservice en VB5 ?
    Par marcsaker dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 08/06/2006, 17h47
  5. Appeler un webservice
    Par pcdingo dans le forum ASP
    Réponses: 5
    Dernier message: 11/01/2006, 14h30

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