Hello to all,

I'm trying to make rails and java-spring app talk to each other
but with no luck...
From rails side: Rails posts the argument to java (correctly I think) but java response is icorrect! From java side: When trying to deploy war file I get error though cxf configuration should be correct because I get what I expected when calling getHello from java service.
Maybe some of you with greater experience in the field could help me out?
Is there something wrong with my wsdl files?

Java app startup error:
2007-11-15 22:22:02,896 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/calculator]] - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'client' defined in ServletContext resource [/WEB-INF/webServiceContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception; nested exception is org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://service.calculator.bsprendimai.lt/}IHelloService. Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception; nested exception is org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://service.calculator.bsprendimai.lt/}IHelloService. Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://service.calculator.bsprendimai.lt/}IHelloService. at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:114) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:208) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:270) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:146) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:89) at org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:83) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:50) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:89)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:118) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:332) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:778) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:705) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1190) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:292) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1305) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1569) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1558)
      at java.lang.Thread.run(Thread.java:595)

Rails wire dump:

= Request

! CONNECT TO localhost:8080
! CONNECTION ESTABLISHED
POST /calculator/services/HelloServiceImpl HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.5 (/187, ruby 1.8.6 (2007-06-07) [i486-linux])
Date: Thu, 15 Nov 2007 20:11:00 GMT
Content-Length: 404
Host: localhost:8080

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<env:Body>
  <n1:getHello xmlns:n1="http://service.calculator.bsprendimai.lt/";>
    <arg0>
      <arg0>Andrius</arg0>
    </arg0>
  </n1:getHello>
</env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
SOAPAction: ""
Content-Type: text/xml;charset=utf-8
Content-Length: 249
Date: Thu, 15 Nov 2007 20:11:00 GMT

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
<soap:Body>
<ns1:getHelloResponse xmlns:ns1="http://service.calculator.bsprendimai.lt/";>
<return>Hello from java,
    </return>
</ns1:getHelloResponse>
</soap:Body>
</soap:Envelope>


--------------------- Rails code---------------------
require 'soap/wsdlDriver'
class HomeController < ApplicationController
        def index
factory = SOAP::WSDLDriverFactory.new("http://localhost:8080/calculator/services/HelloServiceImpl?wsdl";)
        driver  = factory.create_rpc_driver
        driver.generate_explicit_type = true
        driver.wiredump_dev = STDOUT
        render(:text => driver.getHello(:arg0 => "Andrius"))
    end
end

--------------------- Rails wsdl---------------------

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Webservice" xmlns:typens="urn:ActionWebService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; targetNamespace="urn:ActionWebService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns="http://schemas.xmlsoap.org/wsdl/";>
<message name="GetHello">
  <part name="param0" type="xsd:string"/>
</message>
<message name="GetHelloResponse">
  <part name="return" type="xsd:string"/>
</message>
<portType name="WebserviceWebservicePort">
  <operation name="GetHello">

    <input message="typens:GetHello"/>
    <output message="typens:GetHelloResponse"/>
  </operation>
</portType>
<binding name="WebserviceWebserviceBinding" type="typens:WebserviceWebservicePort"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; style="rpc"/>
  <operation name="GetHello">
    <soap:operation soapAction="/webservice/api/GetHello"/>
    <input>

<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; namespace="urn:ActionWebService" use="encoded"/>
    </input>
    <output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; namespace="urn:ActionWebService" use="encoded"/>
    </output>
  </operation>
</binding>
<service name="WebserviceService">
<port name="WebserviceWebservicePort" binding="typens:WebserviceWebserviceBinding">

    <soap:address location="http://localhost:3000/webservice/api"/>
  </port>
</service>
</definitions>

JAVA webservice config:
<bean id="client" class="lt.bsprendimai.calculator.service.IHello" factory-bean="clientFactory" factory-method="create"/> <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"> <property name="serviceClass" value="lt.bsprendimai.calculator.service.IHello"/> <property name="address" value="http://localhost:3000/webservice/api"/> <property name="wsdlURL" value="http://localhost:3000/webservice/service.wsdl"/>
   </bean>

--------------------- JAVA code ---------------------
IHello.java:
package lt.bsprendimai.calculator.service;

import javax.jws.*;
import javax.jws.soap.*;
import javax.jws.soap.SOAPBinding.*;

@WebService
@SOAPBinding(style=Style.RPC, use=Use.ENCODED)
public interface IHello {

   public String getHello(String username);
}

HelloServiceImpl.java:
package lt.bsprendimai.calculator.service;

import lt.bsprendimai.calculator.service.IHello;
import javax.jws.WebService;

@WebService(endpointInterface = "lt.bsprendimai.calculator.service.IHello")
public class HelloServiceImpl implements IHello {

   public String getHello(String username){

       return "Hello from java, "+username;
   }

}

--------------------- Java wsdl---------------------
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:tns="http://service.calculator.bsprendimai.lt/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="HelloServiceImplService" targetNamespace="http://service.calculator.bsprendimai.lt/";>
<wsdl:message name="getHello">
  <wsdl:part name="arg0" type="xsd:string">
  </wsdl:part>
</wsdl:message>
<wsdl:message name="getHelloResponse">
  <wsdl:part name="return" type="xsd:string">
  </wsdl:part>
</wsdl:message>
<wsdl:portType name="IHello">
  <wsdl:operation name="getHello">
    <wsdl:input message="tns:getHello" name="getHello">
  </wsdl:input>
    <wsdl:output message="tns:getHelloResponse" name="getHelloResponse">
  </wsdl:output>
  </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceImplServiceSoapBinding" type="tns:IHello">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <wsdl:operation name="getHello">
    <soap:operation soapAction="" style="rpc"/>
    <wsdl:input name="getHello">
<soap:body namespace="http://service.calculator.bsprendimai.lt/"; use="literal"/>
    </wsdl:input>
    <wsdl:output name="getHelloResponse">
<soap:body namespace="http://service.calculator.bsprendimai.lt/"; use="literal"/>
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloServiceImplService">
<wsdl:port binding="tns:HelloServiceImplServiceSoapBinding" name="HelloServiceImplPort"> <soap:address location="http://localhost:8080/calculator/services/HelloServiceImpl"/>
  </wsdl:port>
</wsdl:service>
</wsdl:definitions>

Reply via email to