Announcement Announcement Module
Collapse
No announcement yet.
How do you call webServices ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 05:20 AM.

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

    Refer to the reference docs for more information.

    Comment


    • #3
      Ok !

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

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            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.

            Comment


            • #7
              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 ?

              Comment


              • #8
                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.

                Comment


                • #9
                  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 !

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      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 !!!
                      Last edited by cicolas; Jun 21st, 2006, 10:41 AM.

                      Comment


                      • #12
                        I'm sorry, I've really run out of ideas :-(.

                        You might want to try the Remoting forum, though. That forum is more related to the problem you have.

                        Comment


                        • #13
                          Just in case someone runs into the same problem, you have to set the servicefactory class in the proxy.

                          Code:
                                 <property name="serviceFactoryClass">
                                      <value>org.apache.axis.client.ServiceFactory</value>
                                  </property>

                          Comment

                          Working...
                          X