<?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; java</title>
	<atom:link href="http://planet.petalslink.com/home/chamerling/tag/java/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>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>
		<item>
		<title>Simple &amp; Useful : Remote debugging with Ant</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/03/25/simple-useful-remote-debugging-with-ant/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/03/25/simple-useful-remote-debugging-with-ant/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 15:13:27 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=74</guid>
		<description><![CDATA[A Ant java call like : &#60;target name=&#160;&#187;run&#160;&#187;&#62; &#60;java classname=&#160;&#187;foo.bar.App&#160;&#187; fork=&#160;&#187;false&#160;&#187;&#62; &#60;classpath refid=&#160;&#187;app.classpath&#160;&#187; /&#62; &#60;/java&#62; &#60;/target&#62; becomes : &#60;target name=&#160;&#187;run&#160;&#187;&#62; &#60;java classname=&#160;&#187;foo.bar.App&#160;&#187; fork=&#160;&#187;yes&#171;&#160;&#62; &#60;classpath refid=&#160;&#187;app.classpath&#160;&#187; /&#62; &#60;sysproperty key=&#160;&#187;DEBUG&#160;&#187; value=&#160;&#187;true&#160;&#187; /&#62; &#60;jvmarg value=&#160;&#187;-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000&#8243; /&#62; &#60;/java&#62; &#60;/target&#62; and is ready to be launch and &#8216;remote debugged&#8217; from a tool like Eclipse IDE.]]></description>
			<content:encoded><![CDATA[<p>A Ant java call like :</p>
<p><em>&lt;target name=&nbsp;&raquo;run&nbsp;&raquo;&gt;<br />
  &lt;java classname=&nbsp;&raquo;foo.bar.App&nbsp;&raquo; fork=&nbsp;&raquo;false&nbsp;&raquo;&gt;<br />
    &lt;classpath refid=&nbsp;&raquo;app.classpath&nbsp;&raquo; /&gt;<br />
  &lt;/java&gt;<br />
&lt;/target&gt;</em></p>
<p>becomes :</p>
<p><em>&lt;target name=&nbsp;&raquo;run&nbsp;&raquo;&gt;<br />
  &lt;java classname=&nbsp;&raquo;foo.bar.App&nbsp;&raquo; fork=&nbsp;&raquo;<strong>yes</strong>&laquo;&nbsp;&gt;<br />
    &lt;classpath refid=&nbsp;&raquo;app.classpath&nbsp;&raquo; /&gt;<br />
 <strong>   &lt;sysproperty key=&nbsp;&raquo;DEBUG&nbsp;&raquo; value=&nbsp;&raquo;true&nbsp;&raquo; /&gt;<br />
    &lt;jvmarg value=&nbsp;&raquo;-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000&#8243; /&gt;</strong><br />
  &lt;/java&gt;<br />
&lt;/target&gt;</em></p>
<p>and is ready to be launch and &#8216;remote debugged&#8217; from a tool like Eclipse IDE.</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/03/25/simple-useful-remote-debugging-with-ant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling static resources with Jetty</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/03/25/handling-static-resources-with-jetty/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/03/25/handling-static-resources-with-jetty/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 10:45:23 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jetty]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=69</guid>
		<description><![CDATA[Here is a quick (and easy) tip on how to handle static resources with Jetty6 (this is really nice and quick to setup such things for a demo ;o)). Here is the code : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick (and easy) tip on how to handle static resources with Jetty6 (this is really nice and quick to setup such things for a demo ;o)). Here is the code :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">foo.bar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Server</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.handler.ContextHandlerCollection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.nio.SelectChannelConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.servlet.Context</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Christophe HAMERLING - eBM WebSourcing
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JettyServer <span style="color: #009900;">&#123;</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: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        Server server <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Server<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> ContextHandlerCollection contexts <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContextHandlerCollection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Context</span> context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Context</span><span style="color: #009900;">&#40;</span>contexts, <span style="color: #0000ff;">&quot;/&quot;</span>, <span style="color: #003399;">Context</span>.<span style="color: #006633;">SESSIONS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        context.<span style="color: #006633;">setResourceBase</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.home&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        context.<span style="color: #006633;">addServlet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;org.mortbay.jetty.servlet.DefaultServlet&quot;</span>, <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">final</span> SelectChannelConnector nioConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SelectChannelConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        nioConnector.<span style="color: #006633;">setPort</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1978</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        server.<span style="color: #006633;">addConnector</span><span style="color: #009900;">&#40;</span>nioConnector<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        server.<span style="color: #006633;">setHandler</span><span style="color: #009900;">&#40;</span>contexts<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        server.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This will display your home directory on <a href="http://localhost:1978">http://localhost:1978</a></p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/03/25/handling-static-resources-with-jetty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

