I was playing around with the Jaxb2 example provided in Xfire 1.2.3
(WeatherService) and I can not get a client to work using the interface
and implementation provided in the example with XFireProxyFactory.  In
debug mode, when the service is called, the service endpoint receives a
null for the zipcode value.  Upon the service implementation returning a
value, I get the following exception client side:

Exception in thread "main" org.codehaus.xfire.XFireRuntimeException:
Could not invoke service.. Nested exception is
org.codehaus.xfire.fault.XFireFault: Could not unmarshall type.
org.codehaus.xfire.fault.XFireFault: Could not unmarshall type.
        at org.codehaus.xfire.jaxb2.JaxbType.readObject(JaxbType.java:211)
        at
org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:160)
        at
org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
        at
org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50)
        at
org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
        at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
        at
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
        at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
        at org.codehaus.xfire.client.Client.invoke(Client.java:335)
        at
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
        at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
        at $Proxy12.GetWeatherByZipCode(Unknown Source)
        at org.codehaus.xfire.jaxb.WeatherClient.main(WeatherClient.java:35)
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.webservicex.net";, local:"GetWeatherByZipCodeResult").
Expected elements are
<{http://www.webservicex.net}GetWeatherByZipCode>,<{http://www.webservicex.net}GetWeatherByZipCodeResponse>
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:525)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:194)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:71)
        at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext
$DefaultRootLoader.childElement(UnmarshallingContext.java:922)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:366)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:347)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:201)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:135)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:337)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:309)
        at org.codehaus.xfire.jaxb2.JaxbType.readObject(JaxbType.java:196)
        ... 16 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.webservicex.net";, local:"GetWeatherByZipCodeResult").
Expected elements are
<{http://www.webservicex.net}GetWeatherByZipCode>,<{http://www.webservicex.net}GetWeatherByZipCodeResponse>
        ... 29 more



Keep in mind, I have not altered any of the classes provided by the
example whatsoever...I merely built and deployed.  Conversely, I used
WsGen to generate client classes per the WSDL generated by XFire and
those work fine.  What am I doing wrong in my client?

Attached is the client class I wrote using the XFireProxyFactory.

Thanks,
Eric Miles
package org.codehaus.xfire.jaxb;

import net.webservicex.GetWeatherByZipCode;
import net.webservicex.GetWeatherByZipCodeResponse;

import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbServiceFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

public class WeatherClient {
	
	public WeatherClient() {
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		
		String url = "http://localhost:9090/jaxb2/services/WeatherService";;
		//String url = "http://localhost:9090/jaxb-spring/services/WeatherService";;
		
        JaxbServiceFactory factory = new JaxbServiceFactory();
		//ObjectServiceFactory factory = new ObjectServiceFactory();
        Service serviceModel = factory.create(WeatherServiceImpl.class);

        XFireProxyFactory proxyFactory = new XFireProxyFactory();
        WeatherService service = (WeatherService) proxyFactory.create(serviceModel, url);
        
        
        GetWeatherByZipCode body = new GetWeatherByZipCode();
        body.setZipCode("24060");
        GetWeatherByZipCodeResponse response = service.GetWeatherByZipCode(body);
        System.out.println(response.getGetWeatherByZipCodeResult().toString());

        System.exit(0);

	}

}
---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to