One thing you can try, before and between the calls to 
JaxWsDynamicClientFactory, reset the context classloader.  Also, use a 
separate JaxWsDynamicClientFactory per client.

aka:

ClassLoader cl = Thread.currentThread().getContextClassloader();

 JaxWsDynamicClientFactory dcf =
      JaxWsDynamicClientFactory.newInstance();
  Client clientA =  dcf.createClient(".....");

Thread.currentThread().setContextClassloader(cl);

dcf =
      JaxWsDynamicClientFactory.newInstance();
  Client clientb =  dcf.createClient(".....");

etc....





On Thursday, December 29, 2011 1:50:08 AM miloslavskacel wrote:
> A try to call two CXF-2.5.0 dynamic clients fails with:
> org.apache.cxf.interceptor.Fault: Marshalling Error:
> net.webservicex.GetWeather is not known to this context
> 
> 
> 
> package my.test;
> 
> import javax.xml.namespace.QName;
> 
> import org.apache.cxf.endpoint.Client;
> 
> import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
> 
> public class TwoDynClients {
> 
>     public static void main(String[] args) throws Exception {
> 
>         JaxWsDynamicClientFactory dcf =
> JaxWsDynamicClientFactory.newInstance();
> 
>         Client clientA =
> dcf.createClient("http://www.webservicex.net/stockquote.asmx?WSDL";);
> 
>         Object[] resultA = clientA.invoke(new
> QName("http://www.webserviceX.NET/";, "GetQuote"), "GOOG");
> 
>         System.out.println("resultA: " + resultA[0]);
> 
>         Client clientB =
> dcf.createClient("http://www.webservicex.net/GlobalWeather.asmx?wsdl";);
> 
>         Object[] resultB = clientB.invoke(new
> QName("http://www.webserviceX.NET";, "GetWeather"), new Object[]
> {"Stuttgart", "Germany"} );
> 
>         System.out.println("resultB: " + resultB[0]);
> 
>     }
> 
> }
> 
> 
> 
> The output of snippet above is:
> 
> 
> 29.12.2011 9:37:12 org.apache.cxf.jaxb.JAXBUtils logGeneratedClassNames
> 
> INFO: Created classes: net.webservicex.GetQuote,
> net.webservicex.GetQuoteResponse, net.webservicex.ObjectFactory
> 
> resultA: GOOG639.7012/28/20114:00pm0.00N/AN/AN/A0207.2B639.700.00%473.02 -
> 645.0029.33721.81Google Inc.
> 
> 29.12.2011 9:37:22 org.apache.cxf.jaxb.JAXBUtils logGeneratedClassNames
> 
> INFO: Created classes: net.webservicex.GetCitiesByCountry,
> net.webservicex.GetCitiesByCountryResponse, net.webservicex.GetWeather,
> net.webservicex.GetWeatherResponse, net.webservicex.ObjectFactory
> 
> 29.12.2011 9:37:24 org.apache.cxf.phase.PhaseInterceptorChain
> doDefaultLoggingv
> WARNING: Interceptor for
> {http://www.webserviceX.NET}GlobalWeather#{http://www.webserviceX.NET}GetWea
> ther has thrown exception, unwinding now
> 
> org.apache.cxf.interceptor.Fault: Marshalling Error:
> net.webservicex.GetWeather is not known to this context
> 
>     at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
> 
> 
> 
> 
> 
> 
> When order of clients is changed the second fails.
> 
> Is it OK to use one JaxWsDynamicClientFactory to create both clients?
> 
> 
> Thanks.
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-to-call-2-CXF-dynamic-clients-tp5107299
> p5107299.html Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to