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 ! où le faire et comment ?
Du coup, au lancement, j'ai un super nullPointerException !! :(
Mon code :
- fichier de conf Spring :
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
| <?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:
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 ;
}
} |