<?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; WebService</title>
	<atom:link href="http://planet.petalslink.com/home/chamerling/category/webservice/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>EasyWSDL 1.3 is out</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/08/19/easywsdl-1-3-is-out/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/08/19/easywsdl-1-3-is-out/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 14:00:55 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[easywsdl]]></category>
		<category><![CDATA[ow2]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=152</guid>
		<description><![CDATA[One more new release of OW2-EasyWSDL, the WSDL manipulation library. The EasyWSDL team is pleased to announce the release of EasyWSDL 1.3 You can download it from: http://forge.ow2.org/project/showfiles.php?group_id=334&#38;release_id=3454 Available in this version : Fix some bugs Improve import/include management Use URL instead of URI in WSDL reader Add SimpleContent tag management Change artifact name (More maven [...]]]></description>
			<content:encoded><![CDATA[<p>One more new release of OW2-EasyWSDL, the WSDL manipulation library.</p>
<blockquote><p>The EasyWSDL team is pleased to announce the release of EasyWSDL 1.3<br />
You can download it from: <a href="http://forge.ow2.org/project/showfiles.php?group_id=334&amp;release_id=3454" target="_new">http://forge.ow2.org/project/showfiles.php?group_id=334&amp;release_id=3454</a><br />
Available in this version :</p>
<ul>
<li>Fix some bugs</li>
<li>Improve import/include management</li>
<li>Use URL instead of URI in WSDL reader</li>
<li>Add SimpleContent tag management</li>
<li>Change artifact name (More maven compliant&#8230;)</li>
</ul>
<p>More information is available on EasyWSDL website: <a href="http://easywsdl.ow2.org/" target="_new">http://easywsdl.ow2.org/</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/08/19/easywsdl-1-3-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EasyWSDL 1.2 is out</title>
		<link>http://planet.petalslink.com/home/chamerling/2009/07/09/easywsdl-12-is-out/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2009/07/09/easywsdl-12-is-out/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 07:26:20 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[soa]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[easywsdl]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/?p=138</guid>
		<description><![CDATA[OW2 EasyWSDL WSDL manipulation library has just been released. This release fix many bugs and introduces some new tooling such as java2wsdl (create WSDL from Java interfaces) and xsd2xml (create XML from XSD definition). EasyWSDL is easy since you can manipulate both WSDL 1.1 and WSDL 2.0 with the same object model. // Read a [...]]]></description>
			<content:encoded><![CDATA[<p>OW2 EasyWSDL WSDL manipulation library has just been released. This release fix many bugs and introduces some new tooling such as java2wsdl (create WSDL from Java interfaces) and xsd2xml (create XML from XSD definition).</p>
<p>EasyWSDL is easy since you can manipulate both WSDL 1.1 and WSDL 2.0 with the same object model.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Read a WSDL 1.1 or 2.0</span>
WSDLReader reader <span style="color: #339933;">=</span> WSDLFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newWSDLReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Description desc <span style="color: #339933;">=</span> reader.<span style="color: #006633;">readWSDL</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URI<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://file/path/document.wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Write a WSDL 1.1 or 2.0 (depend of desc version)</span>
<span style="color: #003399;">Document</span> doc <span style="color: #339933;">=</span> WSDLFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newWSDLWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getDocument</span><span style="color: #009900;">&#40;</span>desc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create a WSDL 1.1 or 2.0</span>
Description desc11 <span style="color: #339933;">=</span> WSDLFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newDescription</span><span style="color: #009900;">&#40;</span>WSDLVersionConstants.<span style="color: #006633;">WSDL11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Description desc20 <span style="color: #339933;">=</span> WSDLFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newDescription</span><span style="color: #009900;">&#40;</span>WSDLVersionConstants.<span style="color: #006633;">WSDL20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Once the Description object is loaded from the WSDL document, you can maniulate all parts of the service description. Let&#8217;s look at endpoints :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Endpoints take place in services.</span>
<span style="color: #666666; font-style: italic;">// Select a service</span>
Service service <span style="color: #339933;">=</span> desc.<span style="color: #006633;">getServices</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// List endpoints</span>
<span style="color: #003399;">List</span> endpoints <span style="color: #339933;">=</span> service.<span style="color: #006633;">getEndpoints</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Read specific endpoint</span>
Endpoint specificEndpoint <span style="color: #339933;">=</span> service.<span style="color: #006633;">getEndpoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;endpointName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Add endpoint to service</span>
service.<span style="color: #006633;">addEndpoint</span><span style="color: #009900;">&#40;</span>specificEndpoint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Remove a specific enpoint</span>
service.<span style="color: #006633;">removeEndpoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;endpointName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create endpoint</span>
Endpoint createdEndpoint <span style="color: #339933;">=</span> service.<span style="color: #006633;">createEndpoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
service.<span style="color: #006633;">addEndpoint</span><span style="color: #009900;">&#40;</span>createdEndpoint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Easy!</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2009/07/09/easywsdl-12-is-out/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>
		<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>JSR181 Tip#1</title>
		<link>http://planet.petalslink.com/home/chamerling/2008/11/26/27/</link>
		<comments>http://planet.petalslink.com/home/chamerling/2008/11/26/27/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 18:21:22 +0000</pubDate>
		<dc:creator>Christophe Hamerling</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[PEtALS]]></category>
		<category><![CDATA[WebService]]></category>
		<category><![CDATA[axis2]]></category>
		<category><![CDATA[jsr181]]></category>

		<guid isPermaLink="false">http://blog.ebmwebsourcing.com/home/chamerling/2008/11/26/27/</guid>
		<description><![CDATA[Here is a tip on the PEtALS JSR181 Service Engine (which is also available for all JSR181 annotated classes outside of PEtALS). Today, I spent some time on a customer bug which was not really a bug&#8230; I was quite surprising when he said me that he was unable to get its annotated class working [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a tip on the <a id="ywl3" title="PEtALS" href="http://http;//petals.ow2.org" target="_blank">PEtALS</a> JSR181 Service Engine (which is also available for all JSR181 annotated classes outside of PEtALS).</p>
<p>Today, I spent some time on a customer bug which was not really a bug&#8230; I was quite surprising when he said me that he was unable to get its annotated class working on the component. The error was at instantiation time (first JBI message handling) :</p>
<p><em><span style="font-family: Verdana;color: #444444">org.apache.axis2.AxisFault: The service is unable to load the foo.bar.Service service implementation class. at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:220) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176) at org.ow2.petals.se.jsr181.JBIListener.onJBIMessage(JBIListener.java:120) at org.ow2.petals.component.framework.listener.MessageExchangeProcessor.processInOutAsProvider(MessageExchangeProcessor.java:524) at org.ow2.petals.component.framework.listener.MessageExchangeProcessor.processAsProvider(MessageExchangeProcessor.java:421) at org.ow2.petals.component.framework.listener.MessageExchangeProcessor.process(MessageExchangeProcessor.java:308) at org.ow2.petals.component.framework.listener.MessageExchangeProcessor.run(MessageExchangeProcessor.java:145) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) Caused by: javax.xml.ws.WebServiceException: The service is unable to load the org.ow2.petals.usecase.jsr181.TestService service implementation class. at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:173) at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70) at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:118) at org.apache.axis2.jaxws.server.endpoint.lifecycle.impl.EndpointLifecycleManagerImpl.createServiceInstance(EndpointLifecycleManagerImpl.java:242) at org.apache.axis2.jaxws.server.endpoint.lifecycle.impl.EndpointLifecycleManagerImpl.createServiceInstance(EndpointLifecycleManagerImpl.java:94) at org.apache.axis2.jaxws.server.ServiceInstanceFactoryImpl.createServiceInstance(ServiceInstanceFactoryImpl.java:49) at org.apache.axis2.jaxws.server.EndpointController.handleRequest(EndpointController.java:253) at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:98) at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:159) &#8230; 9 more</span></em></p>
<p>So what? I launched PEtALS in debug mode, and going step by step until the <em>foo.bar.Service</em> class instantiation. &#8216;Hey what&#8217;s up InstanciationException?&#8217;.<br />
This is simply because the <em>foo.bar.Service</em> class contains constructors and not the empty one!</p>
<p>The solution is to remove all the constructors which are not very usefull here (since they can not be used), or add an empty constructor. Now it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://planet.petalslink.com/home/chamerling/2008/11/26/27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

