(was: [xfire-user] Using external properties file)
 
I'm writing a web service using XFire 1.2.6 with JAXB2 bindings in a 
schema-firstdevelopment project. XFire is configured using the services.xml 
file and annotationsand all is working fine.
 
Now I need to start myself the service to set some properties in the 
service'simplementation class before exposing it (thanks to Yanick) but it 
seems that I'm doingsomething wrong as I got the following exception while 
unmarshalling the client request.
 
Nothing changed except the servlet invocation so I guess I'm doing something 
wrongbut I can't help myself.
 
Here's the details:
 
javax.xml.bind.UnmarshalException: unexpected element (uri:"myns", 
local:"schemaVer"). Expected elements are 
<{myns}getUserID>,<{myns}getUserIDResponse>,... 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:203) at 
org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
 at 
org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
 at 
org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:51)
 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.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64) 
at 
org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38) 
at 
org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:304)
 at 
org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:129)
 at 
org.codehaus.xfire.transport.http.XFireServlet.doPost(XFireServlet.java:116) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)...
 
Servlet implementation:
 
import org.codehaus.xfire.jaxb2.JaxbServiceFactory;import 
org.codehaus.xfire.service.invoker.ObjectInvoker;import 
org.codehaus.xfire.service.Service;import 
org.codehaus.xfire.service.invoker.BeanInvoker;import 
org.codehaus.xfire.transport.http.XFireServlet;import 
javax.servlet.ServletException;
 
public class SOAPServlet extends XFireServlet{  public void init() throws 
ServletException  {    super.init();       MyServiceImpl instance = new 
MyServiceImpl();  //instance.setSomeProperty();     JaxbServiceFactory factory 
= new JaxbServiceFactory(getXFire().getTransportManager(), null);    Service 
service = factory.create(MyService.class, "MyService", null, null);    
service.setProperty(ObjectInvoker.SERVICE_IMPL_CLASS, MyServiceImpl.class);    
service.setInvoker(new BeanInvoker(instance));    
getController().getServiceRegistry().register(service);  }}
 
Service interface:
 
import javax.jws.WebMethod;import javax.jws.WebParam;import 
javax.jws.WebService;
@WebService(name="MyServiceIntf")public interface MyService{    @WebMethod    
getUserIDResponse getUserID(@WebParam(name="getUserID") getUserID body);     
@WebMethod    ....
 
Service class implementation:
 
import javax.jws.WebService;import javax.jws.soap.SOAPBinding;
@WebService(serviceName="MyService")@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)public
 class MyServiceImpl implements MyService{ //Some properties     public 
getUserIDResponse getUserID(getUserID body)    .... Client request (conformant 
to the bounded schema):
 
<getUserId xmlns="myns"> <schemaVer name="tdfschema" ver="0.2"/> <userInfo>  
<userID>someuser</userID>  <password>somepwd</password> </userInfo></getUserID>
Thanks for any help
_________________________________________________________________
Crea il tuo gadget e vinci 10 Windows Vista e 30€ di musica!
http://concorsogadget.it.msn.com/

Reply via email to