<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christophe Hamerling [Archive] &#187; cxf</title>
	<atom:link href="http://planet.petalslink.com/home/chamerling/tag/cxf/feed/" rel="self" type="application/rss+xml" />
	<link>http://planet.petalslink.com/home/chamerling</link>
	<description>Things around SOA, Web Services, Open Source and more...</description>
	<lastBuildDate>Wed, 07 Oct 2009 13:16:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Setting timeout on generated JAXWS CXF Clients</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/09/23/setting-timeout-on-generated-jaxws-cxf-clients/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/09/23/setting-timeout-on-generated-jaxws-cxf-clients/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 14:26:25 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[jaxws]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=158</guid>
		<description><![CDATA[When generating client with the CXF (2.2.2 in this case, should apply to all&#8230;) Java API without any configuration file, here is the way to set the client timeout : package org.ow2.petals.kernel.ws.client; &#160; import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.ow2.petals.kernel.ws.api.RuntimeService; &#160; public class Main &#123; &#160; private void createService&#40;&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>When generating client with the CXF (2.2.2 in this case, should apply to all&#8230;) Java API without any configuration file, here is the way to set the client timeout :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.ow2.petals.kernel.ws.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.endpoint.Client</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.frontend.ClientProxy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.jaxws.JaxWsProxyFactoryBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.transport.http.HTTPConduit</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.transports.http.configuration.HTTPClientPolicy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ow2.petals.kernel.ws.api.RuntimeService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> createService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">long</span> timeout <span style="color: #339933;">=</span> 10000L<span style="color: #339933;">;</span>
        JaxWsProxyFactoryBean factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JaxWsProxyFactoryBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setServiceClass</span><span style="color: #009900;">&#40;</span>RuntimeService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:9999/service/Runtime&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        RuntimeService runtimeService <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>RuntimeService<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Client client <span style="color: #339933;">=</span> ClientProxy.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span>runtimeService<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>client <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            HTTPConduit conduit <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>HTTPConduit<span style="color: #009900;">&#41;</span> client.<span style="color: #006633;">getConduit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            HTTPClientPolicy policy <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HTTPClientPolicy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            policy.<span style="color: #006633;">setConnectionTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            policy.<span style="color: #006633;">setReceiveTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            conduit.<span style="color: #006633;">setClient</span><span style="color: #009900;">&#40;</span>policy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>Note that here the RuntimeService class is my JAXWS annotated class.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/09/23/setting-timeout-on-generated-jaxws-cxf-clients/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>An operation with name &#160;&#187; already exists in this service</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/05/14/an-operation-with-name-already-exists-in-this-service/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/05/14/an-operation-with-name-already-exists-in-this-service/#comments</comments>
		<pubDate>Thu, 14 May 2009 13:22:00 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jaxws]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=107</guid>
		<description><![CDATA[Here is a tip on how to avoid this type of exception with JAXWS but before let&#8217;s try to understand why your Service construciton fails&#8230; This exception occurs when your service definition (the Java interface in our case) have some duplicates methods without the same number of parameters (ie method overloading). This exception is totally [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a tip on how to avoid this type of exception with JAXWS but before let&#8217;s try to understand why your Service construciton fails&#8230;</p>
<p>This exception occurs when your service definition (the Java interface in our case) have some duplicates methods without the same number of parameters (ie method overloading). This exception is totally normal since it is quite logic that the resulting Web Service can only have unique operation names :</p>
<ul>
<li>Check a WSDL file. Did you ever see the same operation X times?</li>
<li>The Web Service Engine generally tries to get the operation context from the operation name. Then it will unmarshall the parameters (it will not have a look to the operation parameters to choose the operation like it should be done in the Java Runtime).</li>
</ul>
<p>Here is a service definition sample which will be used in this article :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.googlecode.chamerling.blog.jaxws.duplicate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Christophe HAMERLING
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Service <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> bar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So let&#8217;s implement this interface :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.googlecode.chamerling.blog.jaxws.duplicate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Christophe HAMERLING
 *
 */</span>
@WebService
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceKo <span style="color: #000000; font-weight: bold;">implements</span> Service <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> bar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Let&#8217;s use the JaxWsServerFactoryBean CXF factory (other WS stacks should throw the same exception&#8230;) to expose this service :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.jaxws.JaxWsServerFactoryBean</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Christophe HAMERLING
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> App <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> <span style="color: #003399;">URL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://localhost:9999/chamerling/services/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		JaxWsServerFactoryBean svrFactory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JaxWsServerFactoryBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Service space <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServiceKo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		svrFactory.<span style="color: #006633;">setAddress</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">URL</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ServiceKO&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		svrFactory.<span style="color: #006633;">setServiceBean</span><span style="color: #009900;">&#40;</span>space<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">endpoint</span>.<span style="color: #006633;">Server</span> service <span style="color: #339933;">=</span> svrFactory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Service is available at &quot;</span>
				<span style="color: #339933;">+</span> service.<span style="color: #006633;">getEndpoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getEndpointInfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAddress</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You should have a beautiful stack trace :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">IllegalArgumentException</span><span style="color: #339933;">:</span> An operation with name <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//duplicate.jaxws.blog.chamerling.googlecode.com/}foo] already exists in this service</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">model</span>.<span style="color: #006633;">InterfaceInfo</span>.<span style="color: #006633;">addOperation</span><span style="color: #009900;">&#40;</span>InterfaceInfo.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">71</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">ReflectionServiceFactoryBean</span>.<span style="color: #006633;">createOperation</span><span style="color: #009900;">&#40;</span>ReflectionServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">774</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">jaxws</span>.<span style="color: #006633;">support</span>.<span style="color: #006633;">JaxWsServiceFactoryBean</span>.<span style="color: #006633;">createOperation</span><span style="color: #009900;">&#40;</span>JaxWsServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">484</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">ReflectionServiceFactoryBean</span>.<span style="color: #006633;">createInterface</span><span style="color: #009900;">&#40;</span>ReflectionServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">766</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">ReflectionServiceFactoryBean</span>.<span style="color: #006633;">buildServiceFromClass</span><span style="color: #009900;">&#40;</span>ReflectionServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">361</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">jaxws</span>.<span style="color: #006633;">support</span>.<span style="color: #006633;">JaxWsServiceFactoryBean</span>.<span style="color: #006633;">buildServiceFromClass</span><span style="color: #009900;">&#40;</span>JaxWsServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">525</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">ReflectionServiceFactoryBean</span>.<span style="color: #006633;">initializeServiceModel</span><span style="color: #009900;">&#40;</span>ReflectionServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">422</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">service</span>.<span style="color: #006633;">factory</span>.<span style="color: #006633;">ReflectionServiceFactoryBean</span>.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>ReflectionServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">190</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">jaxws</span>.<span style="color: #006633;">support</span>.<span style="color: #006633;">JaxWsServiceFactoryBean</span>.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>JaxWsServiceFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">164</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">frontend</span>.<span style="color: #006633;">AbstractWSDLBasedEndpointFactory</span>.<span style="color: #006633;">createEndpoint</span><span style="color: #009900;">&#40;</span>AbstractWSDLBasedEndpointFactory.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">frontend</span>.<span style="color: #006633;">ServerFactoryBean</span>.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>ServerFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">117</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">cxf</span>.<span style="color: #006633;">jaxws</span>.<span style="color: #006633;">JaxWsServerFactoryBean</span>.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>JaxWsServerFactoryBean.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">168</span><span style="color: #009900;">&#41;</span>
	at com.<span style="color: #006633;">googlecode</span>.<span style="color: #006633;">chamerling</span>.<span style="color: #006633;">blog</span>.<span style="color: #006633;">jaxws</span>.<span style="color: #006633;">duplicate</span>.<span style="color: #006633;">AppTest</span>.<span style="color: #006633;">testKoService</span><span style="color: #009900;">&#40;</span>AppTest.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">37</span><span style="color: #009900;">&#41;</span>
	at sun.<span style="color: #006633;">reflect</span>.<span style="color: #006633;">NativeMethodAccessorImpl</span>.<span style="color: #006633;">invoke0</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">Native</span> <span style="color: #003399;">Method</span><span style="color: #009900;">&#41;</span>
	at sun.<span style="color: #006633;">reflect</span>.<span style="color: #006633;">NativeMethodAccessorImpl</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>NativeMethodAccessorImpl.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">39</span><span style="color: #009900;">&#41;</span>
	at sun.<span style="color: #006633;">reflect</span>.<span style="color: #006633;">DelegatingMethodAccessorImpl</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>DelegatingMethodAccessorImpl.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span>
	at java.<span style="color: #006633;">lang</span>.<span style="color: #006633;">reflect</span>.<span style="color: #003399;">Method</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Method</span>.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">585</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestCase</span>.<span style="color: #006633;">runTest</span><span style="color: #009900;">&#40;</span>TestCase.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">154</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestCase</span>.<span style="color: #006633;">runBare</span><span style="color: #009900;">&#40;</span>TestCase.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">127</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestResult</span>$1.<span style="color: #006633;">protect</span><span style="color: #009900;">&#40;</span>TestResult.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">106</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestResult</span>.<span style="color: #006633;">runProtected</span><span style="color: #009900;">&#40;</span>TestResult.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">124</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestResult</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>TestResult.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">109</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestCase</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>TestCase.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">118</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestSuite</span>.<span style="color: #006633;">runTest</span><span style="color: #009900;">&#40;</span>TestSuite.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">208</span><span style="color: #009900;">&#41;</span>
	at junit.<span style="color: #006633;">framework</span>.<span style="color: #006633;">TestSuite</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>TestSuite.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">203</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">junit3</span>.<span style="color: #006633;">JUnit3TestReference</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>JUnit3TestReference.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">130</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">TestExecution</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>TestExecution.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">38</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">RemoteTestRunner</span>.<span style="color: #006633;">runTests</span><span style="color: #009900;">&#40;</span>RemoteTestRunner.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">460</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">RemoteTestRunner</span>.<span style="color: #006633;">runTests</span><span style="color: #009900;">&#40;</span>RemoteTestRunner.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">673</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">RemoteTestRunner</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>RemoteTestRunner.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">386</span><span style="color: #009900;">&#41;</span>
	at org.<span style="color: #006633;">eclipse</span>.<span style="color: #006633;">jdt</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">junit</span>.<span style="color: #006633;">runner</span>.<span style="color: #006633;">RemoteTestRunner</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#40;</span>RemoteTestRunner.<span style="color: #006633;">java</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">196</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>So the solution is to use the <span style="text-decoration: line-through">@WebParam</span> @WebMethod annotation. Simply use this annotation to specify unique operation names in your service implementation :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.googlecode.chamerling.blog.jaxws.duplicate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebMethod</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Christophe HAMERLING
 *
 */</span>
@WebService
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceOk <span style="color: #000000; font-weight: bold;">implements</span> Service <span style="color: #009900;">&#123;</span>
&nbsp;
	@WebMethod<span style="color: #009900;">&#40;</span>operationName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo1&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@WebMethod<span style="color: #009900;">&#40;</span>operationName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo2&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> foo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> bar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Sources for this example are availble on my google code project (<a href="http://code.google.com/p/chamerling/" target="_blank">http://code.google.com/p/chamerling/</a>) under <a href="http://code.google.com/p/chamerling/source/browse/#svn/trunk/blog/jaxws-duplicate" target="_blank">http://code.google.com/p/chamerling/source/browse/#svn/trunk/blog/jaxws-duplicate</a></p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/05/14/an-operation-with-name-already-exists-in-this-service/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache CXF Clients : null result when using bad client factory</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/04/09/apache-cxf-clients-null-result-when-using-bad-client-factory/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/04/09/apache-cxf-clients-null-result-when-using-bad-client-factory/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:12:06 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=91</guid>
		<description><![CDATA[Just a quick note to show that the client factory choice is important with Apache CXF 2.1.4. The service interface definition : package org.ow2.petals.usecase.soapaddressing.server; &#160; import javax.jws.WebMethod; import javax.jws.WebService; &#160; /** * @author chamerling - eBM WebSourcing * */ @WebService public interface AddressingService &#123; &#160; /** * Get the local information * * @return */ [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to show that the client factory choice is important with Apache CXF 2.1.4.</p>
<p><strong>The service interface definition :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.ow2.petals.usecase.soapaddressing.server</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebMethod</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author chamerling - eBM WebSourcing
 *
 */</span>
@WebService
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> AddressingService <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Get the local information
     * 
     * @return
     */</span>
    @WebMethod
    <span style="color: #003399;">String</span> getInfo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>The client with the bad client factory :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.ow2.petals.usecase.soapaddressing.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.frontend.ClientProxyFactoryBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ow2.petals.usecase.soapaddressing.server.AddressingService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author chamerling - eBM WebSourcing
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BadFactory <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @param args
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ClientProxyFactoryBean factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClientProxyFactoryBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setServiceClass</span><span style="color: #009900;">&#40;</span>AddressingService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:8084/petals/services/Service01&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        AddressingService client <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AddressingService<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> info <span style="color: #339933;">=</span> client.<span style="color: #006633;">getInfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>With that client code, the Web Service is really invoked, but the result of the getInfo operation is null. So, let&#8217;s do it with the right client factory&#8230;</p>
<p><strong>The client with the good client factory :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.ow2.petals.usecase.soapaddressing.client</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.cxf.jaxws.JaxWsProxyFactoryBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ow2.petals.usecase.soapaddressing.server.AddressingService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author chamerling - eBM WebSourcing
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GoodFactory <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @param args
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        JaxWsProxyFactoryBean factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JaxWsProxyFactoryBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setServiceClass</span><span style="color: #009900;">&#40;</span>AddressingService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        factory.<span style="color: #006633;">setAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://localhost:8084/petals/services/Service01&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        AddressingService client <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AddressingService<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> info <span style="color: #339933;">=</span> client.<span style="color: #006633;">getInfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This time the result is not null and is really the one expected&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/04/09/apache-cxf-clients-null-result-when-using-bad-client-factory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

