You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kan Sun <ka...@googlemail.com> on 2008/06/26 10:52:53 UTC

Create CXF dynamic client invoking WSDL

Hi all

When I try creating a web service client using CXF's dynamic client api to
invoke a wsdl on server side (see the following), an exception was thrown
complaining the operation already exists. All what I'm trying to do here is
simply creating a client, why could this exception be triggered?

*Code:*
import java.net.URL;
import java.net.URLClassLoader;

import javax.xml.namespace.QName;

import org.apache.cxf.endpoint.dynamic.*;
import org.apache.cxf.endpoint.Client;

public class DynamicClient
{
    public static void main(String[] args)
    {
        try
        {
            DynamicClientFactory dcf = DynamicClientFactory.newInstance();
            Client client = dcf.createClient("*http://servicehost?wsdl*");
        }
        catch (Exception e)
        {...}
    }
}

*Output
*log4j:WARN Continuable parsing error 2 and column 69
log4j:WARN Document root element "log4j:configuration", must match DOCTYPE
root "null".
log4j:WARN Continuable parsing error 2 and column 69
log4j:WARN Document is invalid: no grammar found.
log4j:WARN No appenders could be found for logger
(org.apache.cxf.bus.spring.BusApplicationContext).
log4j:WARN Please initialize the log4j system properly.
26-Jun-2008 09:47:17 org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
java.lang.IllegalArgumentException: An operation with name [*operation name*]
already exists in this service
    at
org.apache.cxf.service.model.InterfaceInfo.addOperation(InterfaceInfo.java:71)
    at
org.apache.cxf.wsdl11.WSDLServiceBuilder.buildInterfaceOperation(WSDLServiceBuilder.java:498)
    at
org.apache.cxf.wsdl11.WSDLServiceBuilder.buildInterface(WSDLServiceBuilder.java:492)
    at
org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:286)
    at
org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:156)
    at
org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:138)
    at
org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:94)
    at org.apache.cxf.endpoint.ClientImpl.<init>(ClientImpl.java:129)
    at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:174)
    at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:157)
    at
com.idna.wsconsumer.cxf.dynamic.DynamicClient.main(DynamicClient.java:20)

Many thanks
--
Kan

Re: Create CXF dynamic client invoking WSDL

Posted by Benson Margulies <bi...@gmail.com>.
Roughly, it means that the code generator that runs for the dynamic client
tried to make the same operation twice, since it thought that the WSDL asked
it to.

Can you post the wsdl?

On Thu, Jun 26, 2008 at 4:52 AM, Kan Sun <ka...@googlemail.com> wrote:

> Hi all
>
> When I try creating a web service client using CXF's dynamic client api to
> invoke a wsdl on server side (see the following), an exception was thrown
> complaining the operation already exists. All what I'm trying to do here is
> simply creating a client, why could this exception be triggered?
>
> *Code:*
> import java.net.URL;
> import java.net.URLClassLoader;
>
> import javax.xml.namespace.QName;
>
> import org.apache.cxf.endpoint.dynamic.*;
> import org.apache.cxf.endpoint.Client;
>
> public class DynamicClient
> {
>    public static void main(String[] args)
>    {
>        try
>        {
>            DynamicClientFactory dcf = DynamicClientFactory.newInstance();
>            Client client = dcf.createClient("*http://servicehost?wsdl*");
>        }
>        catch (Exception e)
>        {...}
>    }
> }
>
> *Output
> *log4j:WARN Continuable parsing error 2 and column 69
> log4j:WARN Document root element "log4j:configuration", must match DOCTYPE
> root "null".
> log4j:WARN Continuable parsing error 2 and column 69
> log4j:WARN Document is invalid: no grammar found.
> log4j:WARN No appenders could be found for logger
> (org.apache.cxf.bus.spring.BusApplicationContext).
> log4j:WARN Please initialize the log4j system properly.
> 26-Jun-2008 09:47:17 org.apache.cxf.bus.spring.BusApplicationContext
> getConfigResources
> INFO: No cxf.xml configuration file detected, relying on defaults.
> java.lang.IllegalArgumentException: An operation with name [*operation
> name*]
> already exists in this service
>    at
>
> org.apache.cxf.service.model.InterfaceInfo.addOperation(InterfaceInfo.java:71)
>    at
>
> org.apache.cxf.wsdl11.WSDLServiceBuilder.buildInterfaceOperation(WSDLServiceBuilder.java:498)
>    at
>
> org.apache.cxf.wsdl11.WSDLServiceBuilder.buildInterface(WSDLServiceBuilder.java:492)
>    at
>
> org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:286)
>    at
>
> org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:156)
>    at
>
> org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:138)
>    at
> org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:94)
>    at org.apache.cxf.endpoint.ClientImpl.<init>(ClientImpl.java:129)
>    at
>
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:174)
>    at
>
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:157)
>    at
> com.idna.wsconsumer.cxf.dynamic.DynamicClient.main(DynamicClient.java:20)
>
> Many thanks
> --
> Kan
>