Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How do you call webServices ?

  1. #1
    Join Date
    Jun 2006
    Posts
    15

    Default How do you call webServices ?

    I try to call a existing webService, with HTTPInvokers.
    But, I don't see where is the Spring magic ?

    My ApplicationContext.xml :
    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://..../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.HttpInvokerProxyFactoryBean">
    	<property name="serviceUrl" value="https://.../glue/consultationImageValeurCDN.wsdl
    " />
    	<property name="serviceInterface" value="com.socgen.bva.cdn.consultationimagevaleur.IConsultationImageValeur" />
    </bean>
    
    </beans>
    I don't see how call my WebService in a simple application in console.
    Can you help me ?
    Last edited by cicolas; Jun 20th, 2006 at 04:20 AM.

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    You basically want to use either a JaxRpcPortProxyFactoryBean, or use a HttpInvokerProxyFactoryBean, not both.

    Refer to the reference docs for more information.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Jun 2006
    Posts
    15

    Default Ok !

    But, how call the webService, how bean call ? in my application ?

  4. #4
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #5
    Join Date
    Jun 2006
    Posts
    15

    Default

    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.

  6. #6
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote Originally Posted by cicolas
    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.

    Quote Originally Posted by cicolas
    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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7
    Join Date
    Jun 2006
    Posts
    15

    Default

    So, my new ApplicationContext is now :

    Code:
    <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>
    			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 :
    Code:
    BeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/ApplicationContext.xml"));
        	service=(ConsultationImageValeur)factory.getBean("consultWebService");
    But, I have the error :
    Code:
    21 juin 2006 10:27:41 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from file [D:\Utilisat\a432566\Mes Documents\Workspace\SpringTest\src\ApplicationContext.xml]
    21 juin 2006 10:27:42 org.springframework.beans.factory.support.AbstractBeanFactory getBean
    INFO: Creating shared instance of singleton bean 'consultWebService'
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'consultWebService' defined in file [D:\Utilisat\a432566\Mes Documents\Workspace\SpringTest\src\ApplicationContext.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(FactoryFinder.java:44)
    	at javax.xml.rpc.FactoryFinder.find(FactoryFinder.java:137)
    	at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:58)
    	at org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory.createServiceFactory(LocalJaxRpcServiceFactory.java:163)
    ...
    And, I don't know where can i find this class, in what jar file ?

  8. #8
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  9. #9
    Join Date
    Jun 2006
    Posts
    15

    Default

    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 !

  10. #10
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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, 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
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •