Hi all,

I am just getting started with CXF and I'm trying to get a basic consumer
working (it's so simple it's almost a "Hello World" example).

The problem, in a nutshell, is I'm getting the following exception when I
run the program:

$ java -cp target/weather-client-jar-with-dependencies.jar \
    com.logicsector.soapclient.SoapClient
[17:15:40,799 INFO  org.apache.cxf.bus.spring.BusApplicationContext]:
Refreshing org.apache.cxf.bus.spring.BusApplicatio
[EMAIL PROTECTED]: display name
[EMAIL PROTECTED]; startup date
[Wed Oct 15 17:15
:40 PDT 2008]; root of context hierarchy
Oct 15, 2008 5:15:40 PM org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
[17:15:40,987 INFO  org.apache.cxf.bus.spring.BusApplicationContext]: Bean
factory for application context [org.apache.c
[EMAIL PROTECTED]:
[EMAIL PROTECTED]
d
[17:15:41,034 INFO  org.apache.cxf.bus.spring.BusApplicationContext]: Bean
'org.apache.cxf.bus.spring.Jsr250BeanPostProc
essor' is not eligible for getting processed by all BeanPostProcessors
(for example: not eligible for auto-proxying)
[17:15:41,034 INFO  org.apache.cxf.bus.spring.BusApplicationContext]: Bean
'org.apache.cxf.bus.spring.BusExtensionPostPr
ocessor' is not eligible for getting processed by all BeanPostProcessors
(for example: not eligible for auto-proxying)
[17:15:41,049 INFO 
org.springframework.beans.factory.support.DefaultListableBeanFactory]:
Pre-instantiating singletons
in
[EMAIL PROTECTED]:
defining beans [cxf,org.apache.cxf.bus.s
pring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusE
xtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.bin
ding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorM
anager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.a
pache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycl
eManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.c
xf.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.policy.NoOpPolicyInterceptorP
rovider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
root of factory hierarchy
Oct 15, 2008 5:15:41 PM
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service {http://weatherws.ws.cdyne.com/}WeatherService from
class com.cdyne.ws.weatherws.Weather
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.j
ava:391)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.
java:258)
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java
:146)
        at
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:52)
        at
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
        at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:93)
        at com.logicsector.soapclient.SoapClient.main(SoapClient.java:23)
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.j
ava:381)
        ... 6 more

I'm trying to access CDyne's SOAP weather interface, which is described here:
    http://wiki.cdyne.com/wiki/index.php?title=CDYNE_Weather
Their WSDL is here:
    http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl

I'm generating the client stub code using wsdl2java via Maven.  When I
look at the generated code, it looks like the Weather.java class extends
Service, so I presume that's the class I need to use in my client code
(I'm not sure if that's right, but it seems correct...?).  The code for my
simple client is shown below:

package com.logicsector.soapclient;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cdyne.ws.weatherws.ForecastReturn;
import com.cdyne.ws.weatherws.Weather;
import com.cdyne.ws.weatherws.WeatherSoap;

public class SoapClient {
    private static final Logger LOGGER =
LoggerFactory.getLogger(SoapClient.class);

    public static void main(String[] args) {
        // Get a reference to the SOAP service.
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(Weather.class);
        factory.setAddress("http://ws.cdyne.com/WeatherWS/Weather.asmx";);
        factory.getInInterceptors().add(new LoggingInInterceptor());
        factory.getOutInterceptors().add(new LoggingOutInterceptor());
        Weather weatherService = (Weather) factory.create();
        LOGGER.debug("Weather (weatherService=subclass of Service)
instance: {}", weatherService);

        // Send a weather request for zip code 94025.
        WeatherSoap weatherSoap = weatherService.getWeatherSoap();
        LOGGER.debug("weatherSoap instance: {}", weatherSoap);
        ForecastReturn forecastReturn =
weatherSoap.getCityForecastByZIP("94025");
        LOGGER.debug("forecastReturn: {}", forecastReturn);
    }
}

I'm compiling my code with Maven.  The pom.xml file is shown below:

<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>com.logicsector</groupId>
    <artifactId>weather-client</artifactId>
    <version>1.0</version>
    <name>Weather SOAP client</name>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.2</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>weather-client</finalName>
        <plugins>
            <!-- Generate Java classes from WSDL during build -->
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    
<wsdl>${basedir}/src/main/wsdl/weather.wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-client</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Add generated sources - avoids having to copy generated
sources to build location -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                
<source>${basedir}/target/generated/src/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Build the JAR with dependencies -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
        <!-- Build with Java 1.5 -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

I am building with the following command:
mvn clean assembly:assembly

I run the compiled client with this command:
java -cp target/weather-client-jar-with-dependencies.jar \
  com.logicsector.soapclient.SoapClient

That's basically the entire contents of my project.  Is there anything
missing that CXF needs that I don't have (such as a configuration file, or
some such)?

I've zipped up a copy of the project at LogicSector.com in case you want
to try downloading it:
http://www.logicsector.com/justin/java/weather-client.zip

Thanks in advance for any help!

Justin Morgan
Logic Sector



Reply via email to