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}GetWeather
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-tp5107299p5107299.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to