View Full Version : How do you call webServices ?
cicolas
Jun 20th, 2006, 04:16 AM
I try to call a existing webService, with HTTPInvokers.
But, I don't see where is the Spring magic ?
My ApplicationContext.xml :
<?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://..../glue/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="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean">
<property name="serviceUrl" value="https://.../glue/consultationImageValeurCDN.wsdl
" />
<property name="serviceInterface" value="com.socgen.bva.cdn.consultationimagevaleur.IConsul tationImageValeur" />
</bean>
</beans>
I don't see how call my WebService in a simple application in console.
Can you help me ?
Arjen Poutsma
Jun 20th, 2006, 10:58 AM
You basically want to use either a JaxRpcPortProxyFactoryBean, or use a HttpInvokerProxyFactoryBean, not both.
Refer to the reference docs (http://static.springframework.org/spring/docs/1.2.x/reference/remoting.html) for more information.
cicolas
Jun 20th, 2006, 11:12 AM
But, how call the webService, how bean call ? in my application ?
Arjen Poutsma
Jun 20th, 2006, 11:18 AM
Well, you have to call a method on the service interface, just like any other class, except that it is can throw a Remote Exception. It is explained here (http://static.springframework.org/spring/docs/1.2.x/reference/remoting.html#d0e12606).
cicolas
Jun 20th, 2006, 11:31 AM
What is the remoting method that i should use?
I don't want modify my webService, and the class that depend of this.
In the doc, the call in the application is abstract for me !
What is the bean that should be call? httpInvokerProxy?
But, I want my class : ConsultationImageValeur !
Thanks.
Arjen Poutsma
Jun 21st, 2006, 05:34 AM
What is the remoting method that i should use?
I don't want modify my webService, and the class that depend of this.
You will probably want to invoke a method on the consultWebService bean. Spring will create a proxy for that (thus implementing ConstultationImageValeur), and that proxy will invoke stuff on the remove, Web service port.
What is the bean that should be call? httpInvokerProxy?
No, you need to remove the httpInvokerProxy, since that has nothing to do with SOAP web services. Use the consultWebService.
cicolas
Jun 21st, 2006, 07:11 AM
So, my new ApplicationContext is now :
<bean id="consultWebService"
class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceInterface">
<value>com.socgen.bva.cdn.consultationimagevaleur.IConsul tationImageValeur</value>
</property>
<!-- <property name="portInterface">
<value>com.socgen.bva.cdn.consultationimagevaleur.Consult ationImageValeur.RemoteConsultationImageValeur</value>
</property> -->
<property name="wsdlDocumentUrl">
<value>
https://asys.dns21.socgen:50249/bva/servlet/glue/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>
And, I call :
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/ApplicationContext.xml"));
service=(ConsultationImageValeur)factory.getBean("consultWebService");
But, I have the error :
21 juin 2006 10:27:41 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
INFO: Loading XML bean definitions from file [D:\Utilisat\a432566\Mes Documents\Workspace\SpringTest\src\ApplicationCont ext.xml]
21 juin 2006 10:27:42 org.springframework.beans.factory.support.Abstract BeanFactory getBean
INFO: Creating shared instance of singleton bean 'consultWebService'
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'consultWebService' defined in file [D:\Utilisat\a432566\Mes Documents\Workspace\SpringTest\src\ApplicationCont ext.xml]: Initialization of bean failed; nested exception is javax.xml.rpc.ServiceException: Provider com.sun.xml.rpc.client.ServiceFactoryImpl not found
javax.xml.rpc.ServiceException: Provider com.sun.xml.rpc.client.ServiceFactoryImpl not found
at javax.xml.rpc.FactoryFinder.newInstance(FactoryFin der.java:44)
at javax.xml.rpc.FactoryFinder.find(FactoryFinder.jav a:137)
at javax.xml.rpc.ServiceFactory.newInstance(ServiceFa ctory.java:58)
at org.springframework.remoting.jaxrpc.LocalJaxRpcSer viceFactory.createServiceFactory(LocalJaxRpcServic eFactory.java:163)
...
And, I don't know where can i find this class, in what jar file ?
Arjen Poutsma
Jun 21st, 2006, 07:23 AM
javax.xml.rpc is part of JAX-RPC, the (older) standard of doing Web services on J2EE. It's part of J2EE 1.4, should it should be provided by your application server. If you don't use a full app server, you can use Axis 1. It implements JAX-RPC.
cicolas
Jun 21st, 2006, 07:43 AM
I include the library of J2EE 1.4, I work with the 1.5, and the application have the same error !
It's not javax.xml.rpc what it search but com.sun.xml.rpc !
Arjen Poutsma
Jun 21st, 2006, 09:57 AM
The javax.xml.rpc package provides the interfaces for JAX-RPC. Spring's JaxRpcPortProxyFactoryBean is based on JAX-RPC, so you will also need an implementation of those interfaces. J2EE 1.4 application servers supply a implementation.
You mention a 1.5 application server. As far as I know, there is only one Java EE 5 app server: Glassfish. Are you using Glassfish? Or are you not using an application server?
If you don't use an application server, you can use Apache Axis 1.4 (http://ws.apache.org/axis/), which implements JAX-RPC. The jar can also be found in the "spring with dependencies" distribution, in the subdirectory lib/axis. You will probably add all three jars located there (axis.jar, saaj.jar, and wsdl4j.jar).
Hope this helps
cicolas
Jun 21st, 2006, 10:12 AM
I have axis-1.3.jar, but not the two others library ! I append also wsdl4j.jar,ans saaj.jar but the error persist.
I don't use Glassfish ! My project in Eclipse is with library JDK 1.5, but my server isn't in this.
One library in 1.4 must be in 1.5 ! Even if, I append the library 1.4, I have the same error !
I try with jaxrpc-api.jar but in this, I finf : javax.xml.rpc, and not : com.sun.xml.rpc !!! :(
Arjen Poutsma
Jun 21st, 2006, 12:10 PM
I'm sorry, I've really run out of ideas :-(.
You might want to try the Remoting forum (http://forum.springframework.org/forumdisplay.php?f=30), though. That forum is more related to the problem you have.
Manuel Palacio
Mar 27th, 2007, 02:32 AM
Just in case someone runs into the same problem, you have to set the servicefactory class in the proxy.
<property name="serviceFactoryClass">
<value>org.apache.axis.client.ServiceFactory</value>
</property>
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.