You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by JoCosti <jo...@steria.com> on 2007/11/12 13:44:28 UTC

classCastExcception in web service client generated with CXF

Hi there,

I'm using 2.0.2 version to generate the client side of an existing web
service. 
I have already managed to write a client with another framework using
jax-rpc technology, I nowwant to migrate to jax-ws with CXF framework

When running the client web service, I'm facing the following exception :

11:25:21,246 [main] INFO  support.DefaultListableBeanFactory  -
Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@89ec59:
defining beans
[cxf,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,{http://anpe.fr/DirectoryServices/}StructureServicesSoap.http-conduit];
root of factory hierarchy
9 nov. 2007 11:25:22
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromWSDL
INFO: Creating Service {http://anpe.fr/DirectoryServices/}StructureServices
from WSDL:
file:/D:/bea_dev/SocleSapiens/StructureServices/src/main/resources/structureservices.wsdl
11:26:31,137 [main] INFO  structures.StructureServicesImpl  - Client web
service StructureServices initialisé
9 nov. 2007 11:26:42 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.ClassCastException: java.lang.String
        at
org.apache.cxf.jaxws.interceptors.HolderOutInterceptor.handleMessage(HolderOutInterceptor.java:95)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
        at
org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy31.getMailAddress(Unknown Source)
        at
fr.anpe.sapiens.services.structures.StructureServicesImpl.getMailAddress(StructureServicesImpl.java:84)
        at
fr.anpe.sapiens.services.structures.StructureServicesTest.testGetMailAddress(StructureServicesTest.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

The service I'm calling looks like this (copied from generated code) :

@ResponseWrapper(targetNamespace = "http://anpe.fr/DirectoryServices/",
className = "fr.anpe.directoryservices.GetMailAddressResponse", localName =
"GetMailAddressResponse")
@RequestWrapper(targetNamespace = "http://anpe.fr/DirectoryServices/",
className = "fr.anpe.directoryservices.GetMailAddress", localName =
"GetMailAddress")
@WebResult(targetNamespace = "http://anpe.fr/DirectoryServices/", name =
"GetMailAddressResult")
@WebMethod(action = "http://anpe.fr/DirectoryServices/GetMailAddress",
operationName = "GetMailAddress")
public java.lang.String getMailAddress(
    @WebParam(targetNamespace = "http://anpe.fr/DirectoryServices/", name =
"applicationName")
    java.lang.String applicationName,
    @WebParam(targetNamespace = "http://anpe.fr/DirectoryServices/", name =
"code")
     java.lang.String code
);

It takes 2 string as parameter and return one, it can't be any simpler, I
have really no idea of what could be wrong ...
Any help would be very welcome.
   
Kind regards,

Joel 

ps : I have already asked help on this problem on a previous post, I prefer
to write a new post to clarify things as previous post was related to
another subject. 
-- 
View this message in context: http://www.nabble.com/classCastExcception-in-web-service-client-generated-with-CXF-tf4790840.html#a13704962
Sent from the cxf-user mailing list archive at Nabble.com.


Re: classCastExcception in web service client generated with CXF

Posted by JoCosti <jo...@steria.com>.
Hi Dan,

I already post an answer concerning my maven problem and the ant migration
but it has not yet appeared in the mailing list (I'm using nable web site to
interact on the mailing).

Ant migration solve the maven problems, but for information purpose here's
the dependency section used in my maven project (copied from CXF maven doc
section)

<dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-frontend-jaxws</artifactId>
   <version>${cxf.version}</version>
</dependency>
<dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-transports-http</artifactId>
   <version>${cxf.version}</version>
</dependency>
<!-- Jetty is needed if you're are not using the CXFServlet -->
<dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-transports-http-jetty</artifactId>
   <version>${cxf.version}</version>
</dependency>
<dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-tools-wsdlto-core</artifactId>
   <version>${cxf.version}</version>
</dependency>

Maven use transitive dependencies so, if the plugin is "well" written, it
should define those indirect dependencies, the other solution is to better
document the maven dependency needed, it's almost impossible to guess that
cxf-rt-bindings-soap or cxf-rt-bindings-http were needed (at least for a CXF
newbie like me ;-).

For the next few days, I won't have time to test your suggestion but I hope
to be able to do it next week.

Anyway, many thanks for your quick answer.
Regards,

Joel


dkulp wrote:
> 
> 
> Joel,
> 
> What are your maven dependencies?   The -exsh true stuff requires the 
> cxf-rt-bindings-soap dependency to work.   Are you also running via the 
> exec plugin (or jetty:run)?   If so, the lack of a couple dependencies 
> could also cause some problems.
> 
> Make sure you have the cxf-rt-frontend-jaxws, cxf-rt-transport-http, and 
> cxf-rt-bindings-soap.   There might be a couple others needed as well.   
> Possibly cxf-rt-bindings-http as your wsdl has an http binding in it, 
> not really sure though.
> 
> Dan
> 
> 
> On Tuesday 13 November 2007, JoCosti wrote:
>> Hi Dan,
>>
>> I'm always happy to be helpful for discovering bug !
>>
>> Well maybe there is another bug concerning
>> cxf-codegen-plugin/wsdl2java maven plugin, adding "-exsh true" option
>> to the plugin leads to a NullPointerException when generating code.
>> (note that without "-exsh true" there is no NPE).
>>
>> Here's the plugin configuration section in my pom.xml :
>> <plugin>
>>    <groupId>org.apache.cxf</groupId>
>>    <artifactId>cxf-codegen-plugin</artifactId>
>>    <version>${cxf.version}</version>
>>    <executions>
>>       <execution>
>>          <id>generate-sources</id>
>>          <phase>generate-sources</phase>
>>          <configuration>
>>
>> <sourceRoot>${project.build.directory}/generated-sources/</sourceRoot>
>>             <wsdlOptions>
>>                <wsdlOption>
>>
>> <wsdl>${basedir}/src/main/resources/structureservices.wsdl</wsdl>
>>                   <extraargs>
>>                      <extraarg>-client</extraarg>
>>                      <extraarg>-exsh</extraarg>
>>                      <extraarg>true</extraarg>
>>                   </extraargs>
>>                </wsdlOption>
>>             </wsdlOptions>
>>          </configuration>
>>          <goals>
>>             <goal>wsdl2java</goal>
>>          </goals>
>>       </execution>
>>    </executions>
>> </plugin>
>>
>> I will try calling directly ant tasks from maven instead of using
>> cxf-codegen plugin to see if the problem is in the maven plugin or in
>> wsdl2java code.
>> I'll keep you informed of my investigation.
>>
>> Regards,
>>
>> Joel
>>
>> dkulp wrote:
>> > Joel,
>> >
>> > Thanks for sending the WSDL.   I can confirm this is a CXF problem.
>> > It's related to the out of band header.   The HolderOutInterceptor
>> > is expecting the out of band header to have a part in the parameter
>> > list if it's an in/out header, but by default, it wasn't generated. 
>> >  It's a bug in the HolderOutInterceptor.
>> >
>> > Good news: I have a possible workaround.   When you run wsdl2java to
>> > generate the code, if you add "-exsh true" to the flags, it will
>> > change the method signature to have the header as a third parameter.
>> >
>> > Dan
>> >
>> > On Monday 12 November 2007, JoCosti wrote:
>> >> Thanks Glenn for the quick and developed answer, I do appreciate a
>> >> lot since I'm a newbie concerning web services and particularly
>> >> jax-ws.
>> >>
>> >> Concerning your remarks :
>> >>
>> >> 1) I think it's doc/literal, here's a part of binding section
>> >>
>> >> 	<wsdl:binding name="StructureServicesSoap"
>> >> type="tns:StructureServicesSoap">
>> >> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>> >> style="document" />
>> >> 		<wsdl:operation name="GetMailAddress">
>> >> 			<soap:operation
>> >> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
>> >> style="document" />
>> >> 			<wsdl:input>
>> >> 				<soap:body use="literal" />
>> >> 				<soap:header
>> >> message="tns:GetMailAddressStructureMailAddressHeader"
>> >> part="StructureMailAddressHeader"
>> >> 					use="literal" />
>> >> 			</wsdl:input>
>> >> 			<wsdl:output>
>> >> 				<soap:body use="literal" />
>> >> 				<soap:header
>> >> message="tns:GetMailAddressStructureMailAddressHeader"
>> >> part="StructureMailAddressHeader"
>> >> 					use="literal" />
>> >> 			</wsdl:output>
>> >> 		</wsdl:operation>
>> >>
>> >> Can you confirm that it should be possible to consume this web
>> >> service with a jax-ws client ?
>> >> I have uploaded the complete wsdl (hope you can have a look at it,
>> >> it's the first time I'm using the upload facility in this mailing
>> >> list).
>> >>
>> >> For 2) I need to have a look at your work, I'm using maven2 to
>> >> generate my web service client, I hope I can use your approach with
>> >> maven.
>> >>
>> >> Finally, here's a the code I have written to call the web service :
>> >>
>> >> the JUnit test part
>> >>
>> >>    public void testGetMailAddress() throws TechniqueException {
>> >>       String mailStructure =
>> >> getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
>> >>       assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
>> >>    }
>> >>
>> >> Where getStructureServices() calls the following code (I've just
>> >> put the interesting part for clarity sake)
>> >>
>> >> // I need to access StructureServices in HTTPS, note sure if it's
>> >> the right way but that's what I've found with googling ...
>> >> Authenticator.setDefault(new AnpeAuthenticator());
>> >> // instanciate the web service client generated by codegen maven
>> >> plugin fr.anpe.directoryservices.StructureServices
>> >> structureServices = new
>> >> fr.anpe.directoryservices.StructureServices();
>> >> // get web service port called StructureServicesSoap
>> >> structureServicesWebServiceConsumer =
>> >> structureServices.getStructureServicesSoap();
>> >>
>> >> One last thing, in my wsdl, I have the same name
>> >> (StructureServicesSoap) for a port and a binding, is that correct ?
>> >>
>> >> binding section :
>> >> 	<wsdl:binding name="StructureServicesSoap"
>> >> type="tns:StructureServicesSoap">
>> >> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>> >> style="document" />
>> >> 		<wsdl:operation name="GetInformation">
>> >> 			<soap:operation
>> >> soapAction="http://anpe.fr/DirectoryServices/GetInformation"
>> >> style="document" />
>> >>
>> >> port section :
>> >> 	<wsdl:service name="StructureServices">
>> >> 		<wsdl:port name="StructureServicesSoap"
>> >> binding="tns:StructureServicesSoap">
>> >> 			<soap:address
>> >> location="https://annuairews-int.tempo.anpe.fr/directoryservices/st
>> >>ruc tureservices.asmx" />
>> >> 		</type filter textwsdl:port>
>> >>
>> >> Regards,
>> >>
>> >> Joel
>> >>
>> >> Glen Mazza-2 wrote:
>> >> > More detective work is needed here:
>> >> >
>> >> > 1.)  Are you using an rpc/encoded web service, instead of doc/lit
>> >> > or rpc/lit (Can you show us a part of the wsdl:binding section,
>> >> > that's where you can determine that)--if so, that is not
>> >> > supported by jax-ws. For rpc/encoded, you'll need to use the
>> >> > Dispatch object or SAAJ instead.
>> >> >
>> >> > An RPC/encoded sample using Dispatch object is here:
>> >> > http://www.jroller.com/gmazza/date/20071102
>> >> >
>> >> > 2.)  You may wish to use both Metro and CXF when working with
>> >> > SOAP clients, because, depending on whether or not it fails on
>> >> > both stacks, that helps pinpoint if the problem is (1) with the
>> >> > web service stack or (2) your own code.  If (2), frequently
>> >> > different error messages are given by the two stacks, which can
>> >> > help greatly in troubleshooting the problem with the client code.
>> >> >
>> >> > The "run-client" target of step 5 here[1] shows how this can be
>> >> > done. All that is needed is to switch the <path refid.../>
>> >> > between "cxf.classpath" and "metro.classpath" to activate the
>> >> > different web service stack.  Recompiling is not necessary,
>> >> > because JAX-WS artifacts are interoperable between web service
>> >> > stacks.
>> >> >
>> >> > [1] http://www.jroller.com/gmazza/date/20070817
>> >> >
>> >> > HTH,
>> >> > Glen
>> >> >
>> >> > Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
>> >> >> Hi there,
>> >> >>
>> >> >> I'm using 2.0.2 version to generate the client side of an
>> >> >> existing web service.
>> >> >> I have already managed to write a client with another framework
>> >> >> using jax-rpc technology, I nowwant to migrate to jax-ws with
>> >> >> CXF framework
>> >> >>
>> >> >> When running the client web service, I'm facing the following
>> >> >> exception :
>> >>
>> >> http://www.nabble.com/file/p13706890/structureservices.wsdl
>> >> structureservices.wsdl
>> >
>> > --
>> > J. Daniel Kulp
>> > Principal Engineer
>> > IONA
>> > P: 781-902-8727    C: 508-380-7194
>> > daniel.kulp@iona.com
>> > http://www.dankulp.com/blog
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/classCastExcception-in-web-service-client-generated-with-CXF-tf4790840.html#a13730086
Sent from the cxf-user mailing list archive at Nabble.com.


Re: classCastExcception in web service client generated with CXF

Posted by Daniel Kulp <dk...@apache.org>.
Joel,

What are your maven dependencies?   The -exsh true stuff requires the 
cxf-rt-bindings-soap dependency to work.   Are you also running via the 
exec plugin (or jetty:run)?   If so, the lack of a couple dependencies 
could also cause some problems.

Make sure you have the cxf-rt-frontend-jaxws, cxf-rt-transport-http, and 
cxf-rt-bindings-soap.   There might be a couple others needed as well.   
Possibly cxf-rt-bindings-http as your wsdl has an http binding in it, 
not really sure though.

Dan


On Tuesday 13 November 2007, JoCosti wrote:
> Hi Dan,
>
> I'm always happy to be helpful for discovering bug !
>
> Well maybe there is another bug concerning
> cxf-codegen-plugin/wsdl2java maven plugin, adding "-exsh true" option
> to the plugin leads to a NullPointerException when generating code.
> (note that without "-exsh true" there is no NPE).
>
> Here's the plugin configuration section in my pom.xml :
> <plugin>
>    <groupId>org.apache.cxf</groupId>
>    <artifactId>cxf-codegen-plugin</artifactId>
>    <version>${cxf.version}</version>
>    <executions>
>       <execution>
>          <id>generate-sources</id>
>          <phase>generate-sources</phase>
>          <configuration>
>
> <sourceRoot>${project.build.directory}/generated-sources/</sourceRoot>
>             <wsdlOptions>
>                <wsdlOption>
>
> <wsdl>${basedir}/src/main/resources/structureservices.wsdl</wsdl>
>                   <extraargs>
>                      <extraarg>-client</extraarg>
>                      <extraarg>-exsh</extraarg>
>                      <extraarg>true</extraarg>
>                   </extraargs>
>                </wsdlOption>
>             </wsdlOptions>
>          </configuration>
>          <goals>
>             <goal>wsdl2java</goal>
>          </goals>
>       </execution>
>    </executions>
> </plugin>
>
> I will try calling directly ant tasks from maven instead of using
> cxf-codegen plugin to see if the problem is in the maven plugin or in
> wsdl2java code.
> I'll keep you informed of my investigation.
>
> Regards,
>
> Joel
>
> dkulp wrote:
> > Joel,
> >
> > Thanks for sending the WSDL.   I can confirm this is a CXF problem.
> > It's related to the out of band header.   The HolderOutInterceptor
> > is expecting the out of band header to have a part in the parameter
> > list if it's an in/out header, but by default, it wasn't generated. 
> >  It's a bug in the HolderOutInterceptor.
> >
> > Good news: I have a possible workaround.   When you run wsdl2java to
> > generate the code, if you add "-exsh true" to the flags, it will
> > change the method signature to have the header as a third parameter.
> >
> > Dan
> >
> > On Monday 12 November 2007, JoCosti wrote:
> >> Thanks Glenn for the quick and developed answer, I do appreciate a
> >> lot since I'm a newbie concerning web services and particularly
> >> jax-ws.
> >>
> >> Concerning your remarks :
> >>
> >> 1) I think it's doc/literal, here's a part of binding section
> >>
> >> 	<wsdl:binding name="StructureServicesSoap"
> >> type="tns:StructureServicesSoap">
> >> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> >> style="document" />
> >> 		<wsdl:operation name="GetMailAddress">
> >> 			<soap:operation
> >> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
> >> style="document" />
> >> 			<wsdl:input>
> >> 				<soap:body use="literal" />
> >> 				<soap:header
> >> message="tns:GetMailAddressStructureMailAddressHeader"
> >> part="StructureMailAddressHeader"
> >> 					use="literal" />
> >> 			</wsdl:input>
> >> 			<wsdl:output>
> >> 				<soap:body use="literal" />
> >> 				<soap:header
> >> message="tns:GetMailAddressStructureMailAddressHeader"
> >> part="StructureMailAddressHeader"
> >> 					use="literal" />
> >> 			</wsdl:output>
> >> 		</wsdl:operation>
> >>
> >> Can you confirm that it should be possible to consume this web
> >> service with a jax-ws client ?
> >> I have uploaded the complete wsdl (hope you can have a look at it,
> >> it's the first time I'm using the upload facility in this mailing
> >> list).
> >>
> >> For 2) I need to have a look at your work, I'm using maven2 to
> >> generate my web service client, I hope I can use your approach with
> >> maven.
> >>
> >> Finally, here's a the code I have written to call the web service :
> >>
> >> the JUnit test part
> >>
> >>    public void testGetMailAddress() throws TechniqueException {
> >>       String mailStructure =
> >> getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
> >>       assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
> >>    }
> >>
> >> Where getStructureServices() calls the following code (I've just
> >> put the interesting part for clarity sake)
> >>
> >> // I need to access StructureServices in HTTPS, note sure if it's
> >> the right way but that's what I've found with googling ...
> >> Authenticator.setDefault(new AnpeAuthenticator());
> >> // instanciate the web service client generated by codegen maven
> >> plugin fr.anpe.directoryservices.StructureServices
> >> structureServices = new
> >> fr.anpe.directoryservices.StructureServices();
> >> // get web service port called StructureServicesSoap
> >> structureServicesWebServiceConsumer =
> >> structureServices.getStructureServicesSoap();
> >>
> >> One last thing, in my wsdl, I have the same name
> >> (StructureServicesSoap) for a port and a binding, is that correct ?
> >>
> >> binding section :
> >> 	<wsdl:binding name="StructureServicesSoap"
> >> type="tns:StructureServicesSoap">
> >> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> >> style="document" />
> >> 		<wsdl:operation name="GetInformation">
> >> 			<soap:operation
> >> soapAction="http://anpe.fr/DirectoryServices/GetInformation"
> >> style="document" />
> >>
> >> port section :
> >> 	<wsdl:service name="StructureServices">
> >> 		<wsdl:port name="StructureServicesSoap"
> >> binding="tns:StructureServicesSoap">
> >> 			<soap:address
> >> location="https://annuairews-int.tempo.anpe.fr/directoryservices/st
> >>ruc tureservices.asmx" />
> >> 		</type filter textwsdl:port>
> >>
> >> Regards,
> >>
> >> Joel
> >>
> >> Glen Mazza-2 wrote:
> >> > More detective work is needed here:
> >> >
> >> > 1.)  Are you using an rpc/encoded web service, instead of doc/lit
> >> > or rpc/lit (Can you show us a part of the wsdl:binding section,
> >> > that's where you can determine that)--if so, that is not
> >> > supported by jax-ws. For rpc/encoded, you'll need to use the
> >> > Dispatch object or SAAJ instead.
> >> >
> >> > An RPC/encoded sample using Dispatch object is here:
> >> > http://www.jroller.com/gmazza/date/20071102
> >> >
> >> > 2.)  You may wish to use both Metro and CXF when working with
> >> > SOAP clients, because, depending on whether or not it fails on
> >> > both stacks, that helps pinpoint if the problem is (1) with the
> >> > web service stack or (2) your own code.  If (2), frequently
> >> > different error messages are given by the two stacks, which can
> >> > help greatly in troubleshooting the problem with the client code.
> >> >
> >> > The "run-client" target of step 5 here[1] shows how this can be
> >> > done. All that is needed is to switch the <path refid.../>
> >> > between "cxf.classpath" and "metro.classpath" to activate the
> >> > different web service stack.  Recompiling is not necessary,
> >> > because JAX-WS artifacts are interoperable between web service
> >> > stacks.
> >> >
> >> > [1] http://www.jroller.com/gmazza/date/20070817
> >> >
> >> > HTH,
> >> > Glen
> >> >
> >> > Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
> >> >> Hi there,
> >> >>
> >> >> I'm using 2.0.2 version to generate the client side of an
> >> >> existing web service.
> >> >> I have already managed to write a client with another framework
> >> >> using jax-rpc technology, I nowwant to migrate to jax-ws with
> >> >> CXF framework
> >> >>
> >> >> When running the client web service, I'm facing the following
> >> >> exception :
> >>
> >> http://www.nabble.com/file/p13706890/structureservices.wsdl
> >> structureservices.wsdl
> >
> > --
> > J. Daniel Kulp
> > Principal Engineer
> > IONA
> > P: 781-902-8727    C: 508-380-7194
> > daniel.kulp@iona.com
> > http://www.dankulp.com/blog



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: classCastExcception in web service client generated with CXF

Posted by JoCosti <jo...@steria.com>.
Back !

After some struggling setting classpath, I've ran successfully wsdl2java ant
tasks within maven with -exsh option set to true, I think there may be some
problem in cxf-codegen plugin since it seems ok with ant and ko with maven.

Code generation is running fine but calling the web service is not, an
exception is thrown, here's the stack trace :

13 nov. 2007 11:47:58
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromWSDL
INFO: Creating Service {http://anpe.fr/DirectoryServices/}StructureServices
from WSDL:
file:/D:/bea_dev/SocleSapiens/StructureServices/src/main/resources/structureservices.wsdl
11:47:58,596 [main] ERROR structures.StructureServicesImpl  - Erreur lors de
l'initialisation du client web service StructureServices 
javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException
	at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:263)
	at javax.xml.ws.Service.getPort(Service.java:94)
	at
fr.anpe.directoryservices.StructureServices.getStructureServicesHttpGet(StructureServices.java:77)
	at
fr.anpe.sapiens.services.structures.StructureServicesImpl.getStructureServicesWebServiceProxy(StructureServicesImpl.java:190)
	at
fr.anpe.sapiens.services.structures.StructureServicesImpl.getMailAddress(StructureServicesImpl.java:85)
	at
fr.anpe.sapiens.services.structures.StructureServicesTest.testGetMailAddress(StructureServicesTest.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
	at
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:57)
	at
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:89)
	at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:356)
	at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:261)
	... 21 more
Caused by: org.apache.cxf.BusException: No binding factory for namespace
http://schemas.xmlsoap.org/wsdl/http/ registered.
	at
org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:78)
	at
org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:100)
	at
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:50)
	... 24 more

I have encountered this problem once, Dan suggested me to try 2.0.2 or
2.0.3-SNAPSHOT version, I have tried both with the same exception ! (the
stack trace shown above was gotten with 2.0.3-SNAPSHOT version)

I must add that the web service I'm calling is a secure one as I'm not sure
about how to configure CXF to call a secure web service, it may be the cause
of my problem(s)

Regards,

Joel


JoCosti wrote:
> 
> Hi Dan,
> 
> I'm always happy to be helpful for discovering bug ! 
> 
> Well maybe there is another bug concerning cxf-codegen-plugin/wsdl2java
> maven plugin, adding "-exsh true" option to the plugin leads to a
> NullPointerException when generating code.
> (note that without "-exsh true" there is no NPE).
> 
> Here's the plugin configuration section in my pom.xml : 
> <plugin>
>    <groupId>org.apache.cxf</groupId>
>    <artifactId>cxf-codegen-plugin</artifactId>
>    <version>${cxf.version}</version>
>    <executions>
>       <execution>
>          <id>generate-sources</id>
>          <phase>generate-sources</phase>
>          <configuration>
>            
> <sourceRoot>${project.build.directory}/generated-sources/</sourceRoot>
>             <wsdlOptions>
>                <wsdlOption>
>                  
> <wsdl>${basedir}/src/main/resources/structureservices.wsdl</wsdl>
>                   <extraargs>
>                      <extraarg>-client</extraarg>
>                      <extraarg>-exsh</extraarg>
>                      <extraarg>true</extraarg>
>                   </extraargs>
>                </wsdlOption>
>             </wsdlOptions>
>          </configuration>
>          <goals>
>             <goal>wsdl2java</goal>
>          </goals>
>       </execution>
>    </executions>
> </plugin>
> 
> I will try calling directly ant tasks from maven instead of using
> cxf-codegen plugin to see if the problem is in the maven plugin or in
> wsdl2java code.
> I'll keep you informed of my investigation.
> 
> Regards,
> 
> Joel
> 
> 
> dkulp wrote:
>> 
>> 
>> Joel,
>> 
>> Thanks for sending the WSDL.   I can confirm this is a CXF problem.   
>> It's related to the out of band header.   The HolderOutInterceptor is 
>> expecting the out of band header to have a part in the parameter list if 
>> it's an in/out header, but by default, it wasn't generated.   It's a bug 
>> in the HolderOutInterceptor.
>> 
>> Good news: I have a possible workaround.   When you run wsdl2java to 
>> generate the code, if you add "-exsh true" to the flags, it will change 
>> the method signature to have the header as a third parameter.   
>> 
>> Dan
>> 
>> On Monday 12 November 2007, JoCosti wrote:
>>> Thanks Glenn for the quick and developed answer, I do appreciate a lot
>>> since I'm a newbie concerning web services and particularly jax-ws.
>>>
>>> Concerning your remarks :
>>>
>>> 1) I think it's doc/literal, here's a part of binding section
>>>
>>> 	<wsdl:binding name="StructureServicesSoap"
>>> type="tns:StructureServicesSoap">
>>> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>>> style="document" />
>>> 		<wsdl:operation name="GetMailAddress">
>>> 			<soap:operation
>>> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
>>> style="document" />
>>> 			<wsdl:input>
>>> 				<soap:body use="literal" />
>>> 				<soap:header
>>> message="tns:GetMailAddressStructureMailAddressHeader"
>>> part="StructureMailAddressHeader"
>>> 					use="literal" />
>>> 			</wsdl:input>
>>> 			<wsdl:output>
>>> 				<soap:body use="literal" />
>>> 				<soap:header
>>> message="tns:GetMailAddressStructureMailAddressHeader"
>>> part="StructureMailAddressHeader"
>>> 					use="literal" />
>>> 			</wsdl:output>
>>> 		</wsdl:operation>
>>>
>>> Can you confirm that it should be possible to consume this web service
>>> with a jax-ws client ?
>>> I have uploaded the complete wsdl (hope you can have a look at it,
>>> it's the first time I'm using the upload facility in this mailing
>>> list).
>>>
>>> For 2) I need to have a look at your work, I'm using maven2 to
>>> generate my web service client, I hope I can use your approach with
>>> maven.
>>>
>>> Finally, here's a the code I have written to call the web service :
>>>
>>> the JUnit test part
>>>
>>>    public void testGetMailAddress() throws TechniqueException {
>>>       String mailStructure =
>>> getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
>>>       assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
>>>    }
>>>
>>> Where getStructureServices() calls the following code (I've just put
>>> the interesting part for clarity sake)
>>>
>>> // I need to access StructureServices in HTTPS, note sure if it's the
>>> right way but that's what I've found with googling ...
>>> Authenticator.setDefault(new AnpeAuthenticator());
>>> // instanciate the web service client generated by codegen maven
>>> plugin fr.anpe.directoryservices.StructureServices structureServices =
>>> new fr.anpe.directoryservices.StructureServices();
>>> // get web service port called StructureServicesSoap
>>> structureServicesWebServiceConsumer =
>>> structureServices.getStructureServicesSoap();
>>>
>>> One last thing, in my wsdl, I have the same name
>>> (StructureServicesSoap) for a port and a binding, is that correct ?
>>>
>>> binding section :
>>> 	<wsdl:binding name="StructureServicesSoap"
>>> type="tns:StructureServicesSoap">
>>> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>>> style="document" />
>>> 		<wsdl:operation name="GetInformation">
>>> 			<soap:operation
>>> soapAction="http://anpe.fr/DirectoryServices/GetInformation"
>>> style="document" />
>>>
>>> port section :
>>> 	<wsdl:service name="StructureServices">
>>> 		<wsdl:port name="StructureServicesSoap"
>>> binding="tns:StructureServicesSoap">
>>> 			<soap:address
>>> location="https://annuairews-int.tempo.anpe.fr/directoryservices/struc
>>>tureservices.asmx" />
>>> 		</type filter textwsdl:port>
>>>
>>> Regards,
>>>
>>> Joel
>>>
>>> Glen Mazza-2 wrote:
>>> > More detective work is needed here:
>>> >
>>> > 1.)  Are you using an rpc/encoded web service, instead of doc/lit or
>>> > rpc/lit (Can you show us a part of the wsdl:binding section, that's
>>> > where you can determine that)--if so, that is not supported by
>>> > jax-ws. For rpc/encoded, you'll need to use the Dispatch object or
>>> > SAAJ instead.
>>> >
>>> > An RPC/encoded sample using Dispatch object is here:
>>> > http://www.jroller.com/gmazza/date/20071102
>>> >
>>> > 2.)  You may wish to use both Metro and CXF when working with SOAP
>>> > clients, because, depending on whether or not it fails on both
>>> > stacks, that helps pinpoint if the problem is (1) with the web
>>> > service stack or (2) your own code.  If (2), frequently different
>>> > error messages are given by the two stacks, which can help greatly
>>> > in troubleshooting the problem with the client code.
>>> >
>>> > The "run-client" target of step 5 here[1] shows how this can be
>>> > done. All that is needed is to switch the <path refid.../> between
>>> > "cxf.classpath" and "metro.classpath" to activate the different web
>>> > service stack.  Recompiling is not necessary, because JAX-WS
>>> > artifacts are interoperable between web service stacks.
>>> >
>>> > [1] http://www.jroller.com/gmazza/date/20070817
>>> >
>>> > HTH,
>>> > Glen
>>> >
>>> > Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
>>> >> Hi there,
>>> >>
>>> >> I'm using 2.0.2 version to generate the client side of an existing
>>> >> web service.
>>> >> I have already managed to write a client with another framework
>>> >> using jax-rpc technology, I nowwant to migrate to jax-ws with CXF
>>> >> framework
>>> >>
>>> >> When running the client web service, I'm facing the following
>>> >> exception :
>>>
>>> http://www.nabble.com/file/p13706890/structureservices.wsdl
>>> structureservices.wsdl
>> 
>> 
>> 
>> -- 
>> J. Daniel Kulp
>> Principal Engineer
>> IONA
>> P: 781-902-8727    C: 508-380-7194
>> daniel.kulp@iona.com
>> http://www.dankulp.com/blog
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/classCastExcception-in-web-service-client-generated-with-CXF-tf4790840.html#a13723765
Sent from the cxf-user mailing list archive at Nabble.com.


Re: classCastExcception in web service client generated with CXF

Posted by JoCosti <jo...@steria.com>.
Hi Dan,

I'm always happy to be helpful for discovering bug ! 

Well maybe there is another bug concerning cxf-codegen-plugin/wsdl2java
maven plugin, adding "-exsh true" option to the plugin leads to a
NullPointerException when generating code.
(note that without "-exsh true" there is no NPE).

Here's the plugin configuration section in my pom.xml : 
<plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>${cxf.version}</version>
   <executions>
      <execution>
         <id>generate-sources</id>
         <phase>generate-sources</phase>
         <configuration>
           
<sourceRoot>${project.build.directory}/generated-sources/</sourceRoot>
            <wsdlOptions>
               <wsdlOption>
                 
<wsdl>${basedir}/src/main/resources/structureservices.wsdl</wsdl>
                  <extraargs>
                     <extraarg>-client</extraarg>
                     <extraarg>-exsh</extraarg>
                     <extraarg>true</extraarg>
                  </extraargs>
               </wsdlOption>
            </wsdlOptions>
         </configuration>
         <goals>
            <goal>wsdl2java</goal>
         </goals>
      </execution>
   </executions>
</plugin>

I will try calling directly ant tasks from maven instead of using
cxf-codegen plugin to see if the problem is in the maven plugin or in
wsdl2java code.
I'll keep you informed of my investigation.

Regards,

Joel


dkulp wrote:
> 
> 
> Joel,
> 
> Thanks for sending the WSDL.   I can confirm this is a CXF problem.   
> It's related to the out of band header.   The HolderOutInterceptor is 
> expecting the out of band header to have a part in the parameter list if 
> it's an in/out header, but by default, it wasn't generated.   It's a bug 
> in the HolderOutInterceptor.
> 
> Good news: I have a possible workaround.   When you run wsdl2java to 
> generate the code, if you add "-exsh true" to the flags, it will change 
> the method signature to have the header as a third parameter.   
> 
> Dan
> 
> On Monday 12 November 2007, JoCosti wrote:
>> Thanks Glenn for the quick and developed answer, I do appreciate a lot
>> since I'm a newbie concerning web services and particularly jax-ws.
>>
>> Concerning your remarks :
>>
>> 1) I think it's doc/literal, here's a part of binding section
>>
>> 	<wsdl:binding name="StructureServicesSoap"
>> type="tns:StructureServicesSoap">
>> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>> style="document" />
>> 		<wsdl:operation name="GetMailAddress">
>> 			<soap:operation
>> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
>> style="document" />
>> 			<wsdl:input>
>> 				<soap:body use="literal" />
>> 				<soap:header
>> message="tns:GetMailAddressStructureMailAddressHeader"
>> part="StructureMailAddressHeader"
>> 					use="literal" />
>> 			</wsdl:input>
>> 			<wsdl:output>
>> 				<soap:body use="literal" />
>> 				<soap:header
>> message="tns:GetMailAddressStructureMailAddressHeader"
>> part="StructureMailAddressHeader"
>> 					use="literal" />
>> 			</wsdl:output>
>> 		</wsdl:operation>
>>
>> Can you confirm that it should be possible to consume this web service
>> with a jax-ws client ?
>> I have uploaded the complete wsdl (hope you can have a look at it,
>> it's the first time I'm using the upload facility in this mailing
>> list).
>>
>> For 2) I need to have a look at your work, I'm using maven2 to
>> generate my web service client, I hope I can use your approach with
>> maven.
>>
>> Finally, here's a the code I have written to call the web service :
>>
>> the JUnit test part
>>
>>    public void testGetMailAddress() throws TechniqueException {
>>       String mailStructure =
>> getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
>>       assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
>>    }
>>
>> Where getStructureServices() calls the following code (I've just put
>> the interesting part for clarity sake)
>>
>> // I need to access StructureServices in HTTPS, note sure if it's the
>> right way but that's what I've found with googling ...
>> Authenticator.setDefault(new AnpeAuthenticator());
>> // instanciate the web service client generated by codegen maven
>> plugin fr.anpe.directoryservices.StructureServices structureServices =
>> new fr.anpe.directoryservices.StructureServices();
>> // get web service port called StructureServicesSoap
>> structureServicesWebServiceConsumer =
>> structureServices.getStructureServicesSoap();
>>
>> One last thing, in my wsdl, I have the same name
>> (StructureServicesSoap) for a port and a binding, is that correct ?
>>
>> binding section :
>> 	<wsdl:binding name="StructureServicesSoap"
>> type="tns:StructureServicesSoap">
>> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
>> style="document" />
>> 		<wsdl:operation name="GetInformation">
>> 			<soap:operation
>> soapAction="http://anpe.fr/DirectoryServices/GetInformation"
>> style="document" />
>>
>> port section :
>> 	<wsdl:service name="StructureServices">
>> 		<wsdl:port name="StructureServicesSoap"
>> binding="tns:StructureServicesSoap">
>> 			<soap:address
>> location="https://annuairews-int.tempo.anpe.fr/directoryservices/struc
>>tureservices.asmx" />
>> 		</type filter textwsdl:port>
>>
>> Regards,
>>
>> Joel
>>
>> Glen Mazza-2 wrote:
>> > More detective work is needed here:
>> >
>> > 1.)  Are you using an rpc/encoded web service, instead of doc/lit or
>> > rpc/lit (Can you show us a part of the wsdl:binding section, that's
>> > where you can determine that)--if so, that is not supported by
>> > jax-ws. For rpc/encoded, you'll need to use the Dispatch object or
>> > SAAJ instead.
>> >
>> > An RPC/encoded sample using Dispatch object is here:
>> > http://www.jroller.com/gmazza/date/20071102
>> >
>> > 2.)  You may wish to use both Metro and CXF when working with SOAP
>> > clients, because, depending on whether or not it fails on both
>> > stacks, that helps pinpoint if the problem is (1) with the web
>> > service stack or (2) your own code.  If (2), frequently different
>> > error messages are given by the two stacks, which can help greatly
>> > in troubleshooting the problem with the client code.
>> >
>> > The "run-client" target of step 5 here[1] shows how this can be
>> > done. All that is needed is to switch the <path refid.../> between
>> > "cxf.classpath" and "metro.classpath" to activate the different web
>> > service stack.  Recompiling is not necessary, because JAX-WS
>> > artifacts are interoperable between web service stacks.
>> >
>> > [1] http://www.jroller.com/gmazza/date/20070817
>> >
>> > HTH,
>> > Glen
>> >
>> > Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
>> >> Hi there,
>> >>
>> >> I'm using 2.0.2 version to generate the client side of an existing
>> >> web service.
>> >> I have already managed to write a client with another framework
>> >> using jax-rpc technology, I nowwant to migrate to jax-ws with CXF
>> >> framework
>> >>
>> >> When running the client web service, I'm facing the following
>> >> exception :
>>
>> http://www.nabble.com/file/p13706890/structureservices.wsdl
>> structureservices.wsdl
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/classCastExcception-in-web-service-client-generated-with-CXF-tf4790840.html#a13722300
Sent from the cxf-user mailing list archive at Nabble.com.


Re: classCastExcception in web service client generated with CXF

Posted by Daniel Kulp <dk...@apache.org>.
Joel,

Thanks for sending the WSDL.   I can confirm this is a CXF problem.   
It's related to the out of band header.   The HolderOutInterceptor is 
expecting the out of band header to have a part in the parameter list if 
it's an in/out header, but by default, it wasn't generated.   It's a bug 
in the HolderOutInterceptor.

Good news: I have a possible workaround.   When you run wsdl2java to 
generate the code, if you add "-exsh true" to the flags, it will change 
the method signature to have the header as a third parameter.   

Dan

On Monday 12 November 2007, JoCosti wrote:
> Thanks Glenn for the quick and developed answer, I do appreciate a lot
> since I'm a newbie concerning web services and particularly jax-ws.
>
> Concerning your remarks :
>
> 1) I think it's doc/literal, here's a part of binding section
>
> 	<wsdl:binding name="StructureServicesSoap"
> type="tns:StructureServicesSoap">
> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="document" />
> 		<wsdl:operation name="GetMailAddress">
> 			<soap:operation
> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
> style="document" />
> 			<wsdl:input>
> 				<soap:body use="literal" />
> 				<soap:header
> message="tns:GetMailAddressStructureMailAddressHeader"
> part="StructureMailAddressHeader"
> 					use="literal" />
> 			</wsdl:input>
> 			<wsdl:output>
> 				<soap:body use="literal" />
> 				<soap:header
> message="tns:GetMailAddressStructureMailAddressHeader"
> part="StructureMailAddressHeader"
> 					use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
>
> Can you confirm that it should be possible to consume this web service
> with a jax-ws client ?
> I have uploaded the complete wsdl (hope you can have a look at it,
> it's the first time I'm using the upload facility in this mailing
> list).
>
> For 2) I need to have a look at your work, I'm using maven2 to
> generate my web service client, I hope I can use your approach with
> maven.
>
> Finally, here's a the code I have written to call the web service :
>
> the JUnit test part
>
>    public void testGetMailAddress() throws TechniqueException {
>       String mailStructure =
> getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
>       assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
>    }
>
> Where getStructureServices() calls the following code (I've just put
> the interesting part for clarity sake)
>
> // I need to access StructureServices in HTTPS, note sure if it's the
> right way but that's what I've found with googling ...
> Authenticator.setDefault(new AnpeAuthenticator());
> // instanciate the web service client generated by codegen maven
> plugin fr.anpe.directoryservices.StructureServices structureServices =
> new fr.anpe.directoryservices.StructureServices();
> // get web service port called StructureServicesSoap
> structureServicesWebServiceConsumer =
> structureServices.getStructureServicesSoap();
>
> One last thing, in my wsdl, I have the same name
> (StructureServicesSoap) for a port and a binding, is that correct ?
>
> binding section :
> 	<wsdl:binding name="StructureServicesSoap"
> type="tns:StructureServicesSoap">
> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="document" />
> 		<wsdl:operation name="GetInformation">
> 			<soap:operation
> soapAction="http://anpe.fr/DirectoryServices/GetInformation"
> style="document" />
>
> port section :
> 	<wsdl:service name="StructureServices">
> 		<wsdl:port name="StructureServicesSoap"
> binding="tns:StructureServicesSoap">
> 			<soap:address
> location="https://annuairews-int.tempo.anpe.fr/directoryservices/struc
>tureservices.asmx" />
> 		</type filter textwsdl:port>
>
> Regards,
>
> Joel
>
> Glen Mazza-2 wrote:
> > More detective work is needed here:
> >
> > 1.)  Are you using an rpc/encoded web service, instead of doc/lit or
> > rpc/lit (Can you show us a part of the wsdl:binding section, that's
> > where you can determine that)--if so, that is not supported by
> > jax-ws. For rpc/encoded, you'll need to use the Dispatch object or
> > SAAJ instead.
> >
> > An RPC/encoded sample using Dispatch object is here:
> > http://www.jroller.com/gmazza/date/20071102
> >
> > 2.)  You may wish to use both Metro and CXF when working with SOAP
> > clients, because, depending on whether or not it fails on both
> > stacks, that helps pinpoint if the problem is (1) with the web
> > service stack or (2) your own code.  If (2), frequently different
> > error messages are given by the two stacks, which can help greatly
> > in troubleshooting the problem with the client code.
> >
> > The "run-client" target of step 5 here[1] shows how this can be
> > done. All that is needed is to switch the <path refid.../> between
> > "cxf.classpath" and "metro.classpath" to activate the different web
> > service stack.  Recompiling is not necessary, because JAX-WS
> > artifacts are interoperable between web service stacks.
> >
> > [1] http://www.jroller.com/gmazza/date/20070817
> >
> > HTH,
> > Glen
> >
> > Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
> >> Hi there,
> >>
> >> I'm using 2.0.2 version to generate the client side of an existing
> >> web service.
> >> I have already managed to write a client with another framework
> >> using jax-rpc technology, I nowwant to migrate to jax-ws with CXF
> >> framework
> >>
> >> When running the client web service, I'm facing the following
> >> exception :
>
> http://www.nabble.com/file/p13706890/structureservices.wsdl
> structureservices.wsdl



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: classCastExcception in web service client generated with CXF

Posted by Glen Mazza <gl...@verizon.net>.
Am Montag, den 12.11.2007, 06:54 -0800 schrieb JoCosti:
> Thanks Glenn for the quick and developed answer, I do appreciate a lot
> since
> I'm a newbie concerning web services and particularly jax-ws.
> 
> Concerning your remarks : 
> 
> 1) I think it's doc/literal, here's a part of binding section 
> 
> 	<wsdl:binding name="StructureServicesSoap"
> type="tns:StructureServicesSoap">
> 		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="document" />
> 		<wsdl:operation name="GetMailAddress">
> 			<soap:operation
> soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
> style="document" />
> 			<wsdl:input>
> 				<soap:body use="literal" />
> 				<soap:header
> message="tns:GetMailAddressStructureMailAddressHeader"
> part="StructureMailAddressHeader"
> 					use="literal" />
> 			</wsdl:input>
> 			<wsdl:output>
> 				<soap:body use="literal" />
> 				<soap:header
> message="tns:GetMailAddressStructureMailAddressHeader"
> part="StructureMailAddressHeader"
> 					use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
> 
> Can you confirm that it should be possible to consume this web service
> with
> a jax-ws client ?

Yes, looks like doc-lit to me.  You should be fine.

> I have uploaded the complete wsdl (hope you can have a look at it, it's the
> first time I'm using the upload facility in this mailing list). 
> 

Sorry, I don't have the time right now.


> For 2) I need to have a look at your work, I'm using maven2 to
> generate my
> web service client, I hope I can use your approach with maven.
> 

You're ahead of me then--I only use Maven for CXF code and a small
webapp I'm building.  Still, you should be able to understand Ant.


>    
> One last thing, in my wsdl, I have the same name (StructureServicesSoap) for
> a port and a binding, is that correct ? 
> 

You can, but it makes things confusing.  If you follow the nomenclature
given in part #2 of my notes (which came from a Metro sample), it makes
understanding the artifacts generated (in particular, mapping the
artifacts to their counterpart in the WSDL) much simpler:

http://www.jroller.com/gmazza/date/20071019#notes

Regards,
Glen



Re: classCastExcception in web service client generated with CXF

Posted by JoCosti <jo...@steria.com>.
Thanks Glenn for the quick and developed answer, I do appreciate a lot since
I'm a newbie concerning web services and particularly jax-ws.

Concerning your remarks : 

1) I think it's doc/literal, here's a part of binding section 

	<wsdl:binding name="StructureServicesSoap"
type="tns:StructureServicesSoap">
		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
		<wsdl:operation name="GetMailAddress">
			<soap:operation
soapAction="http://anpe.fr/DirectoryServices/GetMailAddress"
style="document" />
			<wsdl:input>
				<soap:body use="literal" />
				<soap:header message="tns:GetMailAddressStructureMailAddressHeader"
part="StructureMailAddressHeader"
					use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
				<soap:header message="tns:GetMailAddressStructureMailAddressHeader"
part="StructureMailAddressHeader"
					use="literal" />
			</wsdl:output>
		</wsdl:operation>

Can you confirm that it should be possible to consume this web service with
a jax-ws client ?
I have uploaded the complete wsdl (hope you can have a look at it, it's the
first time I'm using the upload facility in this mailing list). 

For 2) I need to have a look at your work, I'm using maven2 to generate my
web service client, I hope I can use your approach with maven.

Finally, here's a the code I have written to call the web service : 

the JUnit test part

   public void testGetMailAddress() throws TechniqueException {
      String mailStructure =
getStructureServices().getMailAddress(APPLICATION_NOM, "92053");
      assertEquals("ale.courbevoie@TEMPO.anpe.fr", mailStructure);
   }

Where getStructureServices() calls the following code (I've just put the
interesting part for clarity sake)

// I need to access StructureServices in HTTPS, note sure if it's the right
way but that's what I've found with googling ...  
Authenticator.setDefault(new AnpeAuthenticator());
// instanciate the web service client generated by codegen maven plugin
fr.anpe.directoryservices.StructureServices structureServices = new
fr.anpe.directoryservices.StructureServices();
// get web service port called StructureServicesSoap
structureServicesWebServiceConsumer =
structureServices.getStructureServicesSoap();
   
One last thing, in my wsdl, I have the same name (StructureServicesSoap) for
a port and a binding, is that correct ? 

binding section : 
	<wsdl:binding name="StructureServicesSoap"
type="tns:StructureServicesSoap">
		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
		<wsdl:operation name="GetInformation">
			<soap:operation
soapAction="http://anpe.fr/DirectoryServices/GetInformation"
style="document" />

port section : 
	<wsdl:service name="StructureServices">
		<wsdl:port name="StructureServicesSoap"
binding="tns:StructureServicesSoap">
			<soap:address
location="https://annuairews-int.tempo.anpe.fr/directoryservices/structureservices.asmx"
/>
		</wsdl:port>

Regards,

Joel   
   

Glen Mazza-2 wrote:
> 
> More detective work is needed here:
> 
> 1.)  Are you using an rpc/encoded web service, instead of doc/lit or
> rpc/lit (Can you show us a part of the wsdl:binding section, that's
> where you can determine that)--if so, that is not supported by jax-ws.
> For rpc/encoded, you'll need to use the Dispatch object or SAAJ instead.
> 
> An RPC/encoded sample using Dispatch object is here:
> http://www.jroller.com/gmazza/date/20071102
> 
> 2.)  You may wish to use both Metro and CXF when working with SOAP
> clients, because, depending on whether or not it fails on both stacks,
> that helps pinpoint if the problem is (1) with the web service stack or
> (2) your own code.  If (2), frequently different error messages are
> given by the two stacks, which can help greatly in troubleshooting the
> problem with the client code.
> 
> The "run-client" target of step 5 here[1] shows how this can be done.
> All that is needed is to switch the <path refid.../> between
> "cxf.classpath" and "metro.classpath" to activate the different web
> service stack.  Recompiling is not necessary, because JAX-WS artifacts
> are interoperable between web service stacks.
> 
> [1] http://www.jroller.com/gmazza/date/20070817
> 
> HTH,
> Glen
> 
> Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
>> Hi there,
>> 
>> I'm using 2.0.2 version to generate the client side of an existing web
>> service. 
>> I have already managed to write a client with another framework using
>> jax-rpc technology, I nowwant to migrate to jax-ws with CXF framework
>> 
>> When running the client web service, I'm facing the following exception :
>> 
> 
> 
> 
> 
http://www.nabble.com/file/p13706890/structureservices.wsdl
structureservices.wsdl 
-- 
View this message in context: http://www.nabble.com/classCastExcception-in-web-service-client-generated-with-CXF-tf4790840.html#a13706890
Sent from the cxf-user mailing list archive at Nabble.com.


Re: classCastExcception in web service client generated with CXF

Posted by Glen Mazza <gl...@verizon.net>.
More detective work is needed here:

1.)  Are you using an rpc/encoded web service, instead of doc/lit or
rpc/lit (Can you show us a part of the wsdl:binding section, that's
where you can determine that)--if so, that is not supported by jax-ws.
For rpc/encoded, you'll need to use the Dispatch object or SAAJ instead.

An RPC/encoded sample using Dispatch object is here:
http://www.jroller.com/gmazza/date/20071102

2.)  You may wish to use both Metro and CXF when working with SOAP
clients, because, depending on whether or not it fails on both stacks,
that helps pinpoint if the problem is (1) with the web service stack or
(2) your own code.  If (2), frequently different error messages are
given by the two stacks, which can help greatly in troubleshooting the
problem with the client code.

The "run-client" target of step 5 here[1] shows how this can be done.
All that is needed is to switch the <path refid.../> between
"cxf.classpath" and "metro.classpath" to activate the different web
service stack.  Recompiling is not necessary, because JAX-WS artifacts
are interoperable between web service stacks.

[1] http://www.jroller.com/gmazza/date/20070817

HTH,
Glen

Am Montag, den 12.11.2007, 04:44 -0800 schrieb JoCosti:
> Hi there,
> 
> I'm using 2.0.2 version to generate the client side of an existing web
> service. 
> I have already managed to write a client with another framework using
> jax-rpc technology, I nowwant to migrate to jax-ws with CXF framework
> 
> When running the client web service, I'm facing the following exception :
>