You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Bryan Hansen <br...@gmail.com> on 2007/08/09 18:05:25 UTC

Service lookup error

Walking through the documentation on creating a service with spring:

http://cwiki.apache.org/CXF20DOC/writing-a-service-with-spring.html

It isn't really clear about how the service gets looked up and the samples
don't have an example similar to the documentation. (They have more in depth
stuff going on, but I just want to mess around with this basic service
first.)

I created a service like the documentation above has listed:

package org.foo.service.web;
import javax.jws.WebService;

@WebService(targetNamespace = "http://foo.org/hello_world",
            endpointInterface = "org.foo.service.web.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    public String sayHi(String text) {
        return "Hello " + text;
    }
}

and a client:

package org.foo.service.web;

import javax.jws.WebService;

@WebService(targetNamespace = "http://foo.org/hello_world", name =
"HelloWorld")
public interface HelloWorld {
    String sayHi(String text);
}

The Spring service (snippet) configuration is:

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <jaxws:endpoint
      id="helloWorld"
      implementor="org.foo.service.web.HelloWorldImpl"
      address="/HelloWorld">
          <jaxws:features>
             <bean class="org.apache.cxf.feature.LoggingFeature"/>
        </jaxws:features>
    </jaxws:endpoint>


and the Spring client configuration is:

<bean id="client" class="org.foo.service.web.HelloWorld"
      factory-bean="clientFactory" factory-method="create"/>

    <bean id="clientFactory" class="
org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
      <property name="serviceClass" value="org.foo.service.web.HelloWorld"/>
      <property name="address" value="http://localhost:8080/foo/HelloWorld
"/>
    </bean>

The service says that it deploys fine in the tomcat logs:

Aug 9, 2007 9:49:38 AM
org.apache.cxf.service.factory.ReflectionServiceFactoryBeanbuildServiceFromClass
INFO: Creating Service
{http://foo.org/hello_world}HelloWorldImplServicefrom class
org.foo.service.web.HelloWorldImpl

When I run the unit test though against the service I get this error:

javax.xml.ws.soap.SOAPFaultException: Could not find destination factory for
transport http://schemas.xmlsoap.org/soap/http
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
:168)
    at $Proxy42.sayHi(Unknown Source)
    at org.lds.ticketing.integration.WebServiceClientTest.testWebService(
WebServiceClientTest.java:15)
    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 junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at org.springframework.test.ConditionalTestCase.runBare(
ConditionalTestCase.java:69)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.OldTestClassRunner.run(
OldTestClassRunner.java:76)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
JUnit4TestReference.java:38)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)
Caused by: java.lang.RuntimeException: Could not find destination factory
for transport http://schemas.xmlsoap.org/soap/http
    at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(
SoapTransportFactory.java:148)
    at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(
AbstractConduitSelector.java:73)
    at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(
UpfrontConduitSelector.java:61)
    at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(
ClientImpl.java:421)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:250)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:204)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
:134)
    ... 22 more

The unit test is this:

import org.junit.Test;
import org.foo.spring.test.AbstractTestNGTransactionalSpringIntegrationTests
;
import org.foo.service.web.HelloWorld;
import org.testng.Assert;

public class WebServiceClientTest extends
AbstractTestNGTransactionalSpringIntegrationTests {

    @Test
    public void testWebService() {

        HelloWorld client = (HelloWorld) applicationContext.getBean
("client");

        String hi = client.sayHi("service");

        Assert.assertEquals(hi, "service", "Should be Equal");
    }

}

What am I missing?

Thanks,

Bryan

Re: Service lookup error

Posted by Dan Diephouse <da...@envoisolutions.com>.
This is a problem with 2.0 unfortunately. You can either use the
2.0.1release candidate:

http://people.apache.org/~dkulp/stage_cxf/2.0.1-incubator_take3/

Or you include also import /META-INF/cxf/cxf-extension-http-jetty.xml. The
one downside with that is that it requires jetty to be on your classpath.
(Also, ordering of the imports matters. I think the servlet one would need
to be after the http-jetty one, but I could be wrong).

Cheers,
- Dan

On 8/9/07, Bryan Hansen <br...@gmail.com> wrote:
>
> Walking through the documentation on creating a service with spring:
>
> http://cwiki.apache.org/CXF20DOC/writing-a-service-with-spring.html
>
> It isn't really clear about how the service gets looked up and the samples
> don't have an example similar to the documentation. (They have more in
> depth
> stuff going on, but I just want to mess around with this basic service
> first.)
>
> I created a service like the documentation above has listed:
>
> package org.foo.service.web;
> import javax.jws.WebService;
>
> @WebService(targetNamespace = "http://foo.org/hello_world",
>             endpointInterface = "org.foo.service.web.HelloWorld")
> public class HelloWorldImpl implements HelloWorld {
>
>     public String sayHi(String text) {
>         return "Hello " + text;
>     }
> }
>
> and a client:
>
> package org.foo.service.web;
>
> import javax.jws.WebService;
>
> @WebService(targetNamespace = "http://foo.org/hello_world", name =
> "HelloWorld")
> public interface HelloWorld {
>     String sayHi(String text);
> }
>
> The Spring service (snippet) configuration is:
>
>     <import resource="classpath:META-INF/cxf/cxf.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>     <jaxws:endpoint
>       id="helloWorld"
>       implementor="org.foo.service.web.HelloWorldImpl"
>       address="/HelloWorld">
>           <jaxws:features>
>              <bean class="org.apache.cxf.feature.LoggingFeature"/>
>         </jaxws:features>
>     </jaxws:endpoint>
>
>
> and the Spring client configuration is:
>
> <bean id="client" class="org.foo.service.web.HelloWorld"
>       factory-bean="clientFactory" factory-method="create"/>
>
>     <bean id="clientFactory" class="
> org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
>       <property name="serviceClass" value="org.foo.service.web.HelloWorld
> "/>
>       <property name="address" value="http://localhost:8080/foo/HelloWorld
> "/>
>     </bean>
>
> The service says that it deploys fine in the tomcat logs:
>
> Aug 9, 2007 9:49:38 AM
>
> org.apache.cxf.service.factory.ReflectionServiceFactoryBeanbuildServiceFromClass
> INFO: Creating Service
> {http://foo.org/hello_world}HelloWorldImplServicefrom class
> org.foo.service.web.HelloWorldImpl
>
> When I run the unit test though against the service I get this error:
>
> javax.xml.ws.soap.SOAPFaultException: Could not find destination factory
> for
> transport http://schemas.xmlsoap.org/soap/http
>     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> :168)
>     at $Proxy42.sayHi(Unknown Source)
>     at org.lds.ticketing.integration.WebServiceClientTest.testWebService(
> WebServiceClientTest.java:15)
>     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 junit.framework.TestCase.runTest(TestCase.java:168)
>     at junit.framework.TestCase.runBare(TestCase.java:134)
>     at org.springframework.test.ConditionalTestCase.runBare(
> ConditionalTestCase.java:69)
>     at junit.framework.TestResult$1.protect(TestResult.java:110)
>     at junit.framework.TestResult.runProtected(TestResult.java:128)
>     at junit.framework.TestResult.run(TestResult.java:113)
>     at junit.framework.TestCase.run(TestCase.java:124)
>     at junit.framework.TestSuite.runTest(TestSuite.java:232)
>     at junit.framework.TestSuite.run(TestSuite.java:227)
>     at org.junit.internal.runners.OldTestClassRunner.run(
> OldTestClassRunner.java:76)
>     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
> JUnit4TestReference.java:38)
>     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
> TestExecution.java:38)
>     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:460)
>     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:673)
>     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> RemoteTestRunner.java:386)
>     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
> Caused by: java.lang.RuntimeException: Could not find destination factory
> for transport http://schemas.xmlsoap.org/soap/http
>     at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(
> SoapTransportFactory.java:148)
>     at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(
> AbstractConduitSelector.java:73)
>     at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(
> UpfrontConduitSelector.java:61)
>     at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(
> ClientImpl.java:421)
>     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:250)
>     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:204)
>     at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
>     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> :134)
>     ... 22 more
>
> The unit test is this:
>
> import org.junit.Test;
> import
> org.foo.spring.test.AbstractTestNGTransactionalSpringIntegrationTests
> ;
> import org.foo.service.web.HelloWorld;
> import org.testng.Assert;
>
> public class WebServiceClientTest extends
> AbstractTestNGTransactionalSpringIntegrationTests {
>
>     @Test
>     public void testWebService() {
>
>         HelloWorld client = (HelloWorld) applicationContext.getBean
> ("client");
>
>         String hi = client.sayHi("service");
>
>         Assert.assertEquals(hi, "service", "Should be Equal");
>     }
>
> }
>
> What am I missing?
>
> Thanks,
>
> Bryan
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog