You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Matthew Pocock <ma...@ncl.ac.uk> on 2008/04/30 19:43:55 UTC

problem with client

Hi,

I'm having trouble connecting a client to a SOAP server. Both the client
and server are implemented using CXF. I can connect to the service using
SoapUI just fine.

I've pasted in the client code, the output and exception I get when
running it, and the maven pom.xml so you've got everything. Any answers
gratefully received.

Matthew

import uk.ac.ncl.cs.instantsoap.wsapi.*;
import static uk.ac.ncl.cs.instantsoap.wsapi.Wsapi.*;
import org.apache.cxf.jaxws.*;
import java.util.Map;

public class Client
{
  public static void main(String[] args)
          throws Throwable
  {
    if(args.length != 1)
    {
       System.out.println("Use: Client serviceUrl");
       System.exit(1);
    }
    String serviceUrl = args[0];

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(WebServiceDispatcher.class);
    factory.setAddress(serviceUrl);
    WebServiceDispatcher dispatcher = (WebServiceDispatcher)
factory.create();

    JobSpecification js = jobSpecification(
            "echoString",
            pair("messageIn", "Hi Mum!"));

    Map<String, String> results = invoke(dispatcher, js);
    System.out.println("The message was: " + results.get("messageOut"));
  }
}

$ java -classpath target/testClient-1.0-jar-with-dependencies.jar Client
http://localhost:8080/instantsoap-ws-echotest-1.0/services/instantsoap/applications
30-Apr-2008 18:42:31
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@df6ccd:
display name [org.apache.cxf.bus.spring.BusApplicationContext@df6ccd];
startup date [Wed Apr 30 18:42:31 BST 2008]; root of context hierarchy
30-Apr-2008 18:42:31 org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
30-Apr-2008 18:42:31
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext@df6ccd]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1c99159
30-Apr-2008 18:42:31
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization
INFO: Bean 'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
30-Apr-2008 18:42:31
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization
INFO: Bean 'org.apache.cxf.bus.spring.BusExtensionPostProcessor' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
30-Apr-2008 18:42:31
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1c99159:
defining beans
[cxf,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org!
 .apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory];
root of factory hierarchy
30-Apr-2008 18:42:32
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service
{http://wsapi.instantsoap.cs.ncl.ac.uk/}WebServiceDispatcherService from
class uk.ac.ncl.cs.instantsoap.wsapi.WebServiceDispatcher
30-Apr-2008 18:42:33
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
fillInSchemaCrossreferences
SEVERE: Schema element
{http://cs.ncl.ac.uk/instantsoap/service}jobSpecification references
undefined type {http://www.w3.org/2001/XMLSchema}anyType for service
{http://wsapi.instantsoap.cs.ncl.ac.uk/}WebServiceDispatcherService.
Exception in thread "main"
org.apache.cxf.service.factory.ServiceConstructionException: Could not
resolve a binding for null
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:310)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:178)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
        at
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
        at
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
        at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
        at Client.main(Client.java:21)
Caused by: org.apache.cxf.BusException: No binding factory for namespace
http://schemas.xmlsoap.org/soap/ registered.
        at
org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:91)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:300)
        ... 6 more

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>mygroup</groupId>
    <artifactId>testClient</artifactId>
    <packaging>jar</packaging>
    <name>Test Client for instantsoap</name>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>uk.ac.ncl.cs.instantsoap</groupId>
            <artifactId>instantsoap-api</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- CXF -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>2.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>2.1-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>fluxion</id>
            <name>Fluxion repository</name>
            <url>http://metagenome.ncl.ac.uk/fluxions/repo</url>
        </repository>
        <repository>
            <id>apache-snapshots</id>
            <name>Apache SNAPSHOT Repository</name>
            <url>http://people.apache.org/repo/m2-snapshot-repository/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>apache-incubating</id>
            <name>Apache Incubating Repository</name>
            <url>http://people.apache.org/repo/m2-incubating-repository/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>fluxion</id>
            <name>Fluxion repository</name>
            <url>http://metagenome.ncl.ac.uk/fluxions/repo</url>
        </pluginRepository>
    </pluginRepositories>
</project>



Re: problem with client

Posted by Daniel Kulp <dk...@apache.org>.
I believe its the "jar-with-dependencies" thing causing problems.   I 
don't think that will work with the individual cxf modules as certains 
files need to be merged together.   I think jar-with-dependencies is 
doing a "first on added wins" thing so that's going to cause issues.

In particular, the META-INF/spring.handlers, META-INF/spring.schemas, and 
META-INF/cxf/cxf.extension files need to be merged.

The best bet is probable to not use the individual modules and instead 
depend on cxf-bundle.   We already merge the stuff together when we 
create the bundle jar.

Dan


On Wednesday 30 April 2008, Matthew Pocock wrote:
> Hi,
>
> I'm having trouble connecting a client to a SOAP server. Both the
> client and server are implemented using CXF. I can connect to the
> service using SoapUI just fine.
>
> I've pasted in the client code, the output and exception I get when
> running it, and the maven pom.xml so you've got everything. Any
> answers gratefully received.
>
> Matthew
>
> import uk.ac.ncl.cs.instantsoap.wsapi.*;
> import static uk.ac.ncl.cs.instantsoap.wsapi.Wsapi.*;
> import org.apache.cxf.jaxws.*;
> import java.util.Map;
>
> public class Client
> {
>   public static void main(String[] args)
>           throws Throwable
>   {
>     if(args.length != 1)
>     {
>        System.out.println("Use: Client serviceUrl");
>        System.exit(1);
>     }
>     String serviceUrl = args[0];
>
>     JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>     factory.setServiceClass(WebServiceDispatcher.class);
>     factory.setAddress(serviceUrl);
>     WebServiceDispatcher dispatcher = (WebServiceDispatcher)
> factory.create();
>
>     JobSpecification js = jobSpecification(
>             "echoString",
>             pair("messageIn", "Hi Mum!"));
>
>     Map<String, String> results = invoke(dispatcher, js);
>     System.out.println("The message was: " +
> results.get("messageOut")); }
> }
>
> $ java -classpath target/testClient-1.0-jar-with-dependencies.jar
> Client
> http://localhost:8080/instantsoap-ws-echotest-1.0/services/instantsoap
>/applications 30-Apr-2008 18:42:31
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing
> org.apache.cxf.bus.spring.BusApplicationContext@df6ccd: display name
> [org.apache.cxf.bus.spring.BusApplicationContext@df6ccd]; startup date
> [Wed Apr 30 18:42:31 BST 2008]; root of context hierarchy 30-Apr-2008
> 18:42:31 org.apache.cxf.bus.spring.BusApplicationContext
> getConfigResources
> INFO: No cxf.xml configuration file detected, relying on defaults.
> 30-Apr-2008 18:42:31
> org.springframework.context.support.AbstractApplicationContext
> obtainFreshBeanFactory
> INFO: Bean factory for application context
> [org.apache.cxf.bus.spring.BusApplicationContext@df6ccd]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@1
>c99159 30-Apr-2008 18:42:31
> org.springframework.context.support.AbstractApplicationContext$BeanPos
>tProcessorChecker postProcessAfterInitialization
> INFO: Bean 'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor' is not
> eligible for getting processed by all BeanPostProcessors (for example:
> not eligible for auto-proxying)
> 30-Apr-2008 18:42:31
> org.springframework.context.support.AbstractApplicationContext$BeanPos
>tProcessorChecker postProcessAfterInitialization
> INFO: Bean 'org.apache.cxf.bus.spring.BusExtensionPostProcessor' is
> not eligible for getting processed by all BeanPostProcessors (for
> example: not eligible for auto-proxying)
> 30-Apr-2008 18:42:31
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@1
>c99159: defining beans
> [cxf,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.
>bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceMa
>nager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.Bi
>ndingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,
>org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WS
>DLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.Wo
>rkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apac
>he.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleM
>anager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.tr
>ansports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointReso
>lverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalo
>g.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRe
>gistry,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,
>org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org!
> .apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.c
>xf.transport.http_jetty.JettyHTTPTransportFactory]; root of factory
> hierarchy
> 30-Apr-2008 18:42:32
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> buildServiceFromClass
> INFO: Creating Service
> {http://wsapi.instantsoap.cs.ncl.ac.uk/}WebServiceDispatcherService
> from class uk.ac.ncl.cs.instantsoap.wsapi.WebServiceDispatcher
> 30-Apr-2008 18:42:33
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> fillInSchemaCrossreferences
> SEVERE: Schema element
> {http://cs.ncl.ac.uk/instantsoap/service}jobSpecification references
> undefined type {http://www.w3.org/2001/XMLSchema}anyType for service
> {http://wsapi.instantsoap.cs.ncl.ac.uk/}WebServiceDispatcherService.
> Exception in thread "main"
> org.apache.cxf.service.factory.ServiceConstructionException: Could not
> resolve a binding for null
>         at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBinding
>Info(AbstractWSDLBasedEndpointFactory.java:310) at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoin
>tInfo(AbstractWSDLBasedEndpointFactory.java:178) at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoin
>t(AbstractWSDLBasedEndpointFactory.java:102) at
> org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.jav
>a:51) at
> org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFacto
>ryBean.java:97) at
> org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBea
>n.java:89) at Client.main(Client.java:21)
> Caused by: org.apache.cxf.BusException: No binding factory for
> namespace http://schemas.xmlsoap.org/soap/ registered.
>         at
> org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(Bin
>dingFactoryManagerImpl.java:91) at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBinding
>Info(AbstractWSDLBasedEndpointFactory.java:300) ... 6 more
>
> <?xml version="1.0"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>mygroup</groupId>
>     <artifactId>testClient</artifactId>
>     <packaging>jar</packaging>
>     <name>Test Client for instantsoap</name>
>     <version>1.0</version>
>
>     <dependencies>
>         <dependency>
>             <groupId>uk.ac.ncl.cs.instantsoap</groupId>
>             <artifactId>instantsoap-api</artifactId>
>             <version>1.0</version>
>         </dependency>
>         <!-- CXF -->
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-frontend-jaxws</artifactId>
>             <version>2.1-SNAPSHOT</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-transports-http</artifactId>
>             <version>2.1-SNAPSHOT</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-transports-http-jetty</artifactId>
>             <version>2.1-SNAPSHOT</version>
>         </dependency>
>     </dependencies>
>
>     <build>
>         <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <configuration>
>                     <source>1.5</source>
>                     <target>1.5</target>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-assembly-plugin</artifactId>
>                 <configuration>
>                     <descriptorRefs>
>                        
> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
>
>     <repositories>
>         <repository>
>             <id>fluxion</id>
>             <name>Fluxion repository</name>
>             <url>http://metagenome.ncl.ac.uk/fluxions/repo</url>
>         </repository>
>         <repository>
>             <id>apache-snapshots</id>
>             <name>Apache SNAPSHOT Repository</name>
>            
> <url>http://people.apache.org/repo/m2-snapshot-repository/</url>
> <snapshots>
>                 <enabled>true</enabled>
>             </snapshots>
>         </repository>
>         <repository>
>             <id>apache-incubating</id>
>             <name>Apache Incubating Repository</name>
>            
> <url>http://people.apache.org/repo/m2-incubating-repository/</url>
> </repository>
>     </repositories>
>     <pluginRepositories>
>         <pluginRepository>
>             <id>fluxion</id>
>             <name>Fluxion repository</name>
>             <url>http://metagenome.ncl.ac.uk/fluxions/repo</url>
>         </pluginRepository>
>     </pluginRepositories>
> </project>



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog