-
Call a Web Service
I'm French ! Excuse-me for the mistakes !
I don't see where my webService is instantiate?
how run a web Service with Spring ?
I see docs, but i don't understand this ! :(
when running => nullPointerException
I want to run a existing webService who is named : ConsultationImageValeur, and return result in the console.
Here is my source code :
- Spring configuration file :
Code:
<?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://.../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>
My main class :
Code:
package socgen.test.spring;
import com.socgen.bva.cdn.consultationimagevaleur.ConsultationImageValeur;
import com.socgen.bva.cdn.consultationimagevaleur.data.niveau1.DataIn1;
import com.socgen.bva.cdn.consultationimagevaleur.data.niveau1.DataOut1;
import com.socgen.bva.cdn.consultationimagevaleur.data.niveau1.in.Actif;
import com.socgen.omg.util.webservices.donnees.DemandeTechniqueCtx;
public class TestAppli {
public TestAppli() {
}
ConsultationImageValeur service ; //The isn't instantiation? :confused:
/**
* @param args
* @throws GenericException
*/
public static void main(String[] args) {
System.out.println("bonjour");
String res = maMethode();
System.out.println(res);
}
public void setService(ConsultationImageValeur service) {
this.service = service;
}
public static String maMethode() {
TestAppli ta = new TestAppli();
DataIn1 param = ta.init();
DataOut1 sortie = ta.serv(param);
String aff = ta.transform(sortie);
return aff;
}
public DataIn1 init() {
DataIn1 param = new DataIn1();
Actif actif = new Actif();
actif.setCotaPlace("025");
actif.setCodeIsin("FR000121568");
param.setActif(actif);
DemandeTechniqueCtx demande = new DemandeTechniqueCtx();
demande.setUtilisateurBanque(...);
demande.setUtilisateurCode("...");
demande.setCanalCode("...");
param.setDemande(demande);
return param;
}
public DataOut1 serv(DataIn1 param) {
//this.service = (ConsultationImageValeur) getWebApplicationContext().getBean("consultWebService");
//System.out.println(getApplicationContext().containsBean("consultWebService"));
//service = (ConsultationImageValeur) getApplicationContext().getBean("consultWebService");
DataOut1 sortie = null;
try {
sortie = service.getValeur(param); // The error is showing here :mad:
} catch (Exception e) {
e.printStackTrace();
}
return sortie;
}
public String transform(DataOut1 sortie) {
String aff = sortie.getActif().getCodeIsin();
return aff ;
}
}
-
I never used the "JaxRpcPortProxyFactoryBean", so i can't help you here.
Maybe you want to look at my echo web service example, the thread is called "Easy Spring-WS App". It's an doc/lit (not rpc/encoded) web service, top-down approach.
Cheers,
Ingo