PDA

View Full Version : Call a Web Service


cicolas
Jun 8th, 2006, 09:48 AM
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 :

<?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.JaxRpcPortProx yFactoryBean">
<property name="serviceInterface">
<value>com.socgen.bva.cdn.consultationimagevaleur.Consult ationImageValeur</value>
</property>
<property name="portInterface">
<value>com.socgen.bva.cdn.consultationimagevaleur.Consult ationImageValeur.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.Consult ationImageValeur">
<property name="service">
<ref bean="consultWebService" />
</property>
</bean>

</beans>

My main class :
package socgen.test.spring;

import com.socgen.bva.cdn.consultationimagevaleur.Consult ationImageValeur;
import com.socgen.bva.cdn.consultationimagevaleur.data.ni veau1.DataIn1;
import com.socgen.bva.cdn.consultationimagevaleur.data.ni veau1.DataOut1;
import com.socgen.bva.cdn.consultationimagevaleur.data.ni veau1.in.Actif;
import com.socgen.omg.util.webservices.donnees.DemandeTec hniqueCtx;

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().contain sBean("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 ;
}
}

res1st
Jun 9th, 2006, 06:46 AM
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