<?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; jaxws</title>
	<atom:link href="http://planet.petalslink.com/home/chamerling/tag/jaxws/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>Easily expose JAXWS in PEtALS with Maven</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/05/26/easily-expose-jaxws-in-petals-with-maven/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/05/26/easily-expose-jaxws-in-petals-with-maven/#comments</comments>
		<pubDate>Tue, 26 May 2009 12:04:29 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[PEtALS]]></category>
		<category><![CDATA[jaxws]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=118</guid>
		<description><![CDATA[Since I am always using command line tools such as Maven or Ant to create my project and to package them, I have just created a new Maven plugin to easily and quickly expose a JAXWS service in PEtALS with Maven. This plugin will generate the JBI Service Unit and Service Assembly from a Maven [...]]]></description>
			<content:encoded><![CDATA[<p>Since I am always using command line tools such as Maven or Ant to create my project and to package them, I have just created a new Maven plugin to easily and quickly expose a JAXWS service in PEtALS with Maven. This plugin will generate the JBI Service Unit and Service Assembly from a Maven java project with just a few lines of Maven settings&#8230;</p>
<p>As an example, the following 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;">org.ow2.petals</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;
@WebService
<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;
	@WebMethod
	<span style="color: #003399;">String</span> ping<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and its 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;">org.ow2.petals</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> ServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> Service <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> ping<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> input<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>will generate a Service Assembly idirectly deployable to PEtALS by the help of the Maven plugin :</p>
<pre>
&lt;build&gt;
	&lt;plugins&gt;
		&lt;plugin&gt;
			&lt;groupId&gt;org.ow2.petals&lt;/groupId&gt;
			&lt;artifactId&gt;maven-petals-jaxws2jbi&lt;/artifactId&gt;
			&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
			&lt;executions&gt;
				&lt;execution&gt;
					&lt;id&gt;generate-jbi&lt;/id&gt;
					&lt;phase&gt;package&lt;/phase&gt;
					&lt;configuration&gt;
						&lt;className&gt;
							org.ow2.petals.ServiceImpl
						&lt;/className&gt;
					&lt;/configuration&gt;
					&lt;goals&gt;
						&lt;goal&gt;java2jbi&lt;/goal&gt;
					&lt;/goals&gt;
				&lt;/execution&gt;
			&lt;/executions&gt;
		&lt;/plugin&gt;
	&lt;/plugins&gt;
&lt;/build&gt;
</pre>
<p>The plugin takes the Service class, generates its associated WSDL file and the JBI descriptor and then package all into a Service Assembly.</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/05/26/easily-expose-jaxws-in-petals-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>

