Announcement Announcement Module
Collapse
No announcement yet.
JiBX Marshaller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JiBX Marshaller

    Does any one know how to configure a Jibx marshaller in a spring-ws?
    if we have a request coming and we want to map that request into an object,do we need to create two classes? one for the object, the other one for marshaller? and modify the spring-ws-servlet.xml?

    Many thanks,
    Qiulu

  • #2
    Hi Qiulu,
    Did you sort this? I'd be interested in your implementation. I'm still finishing mine.

    Cheers
    Glenn

    Comment


    • #3
      I have been using JiBX with Spring WS for a couple of years now. Here is a simple example (I typed this in TextPad, so there may be a few typos):

      Spring config:
      Code:
      <bean id="fooEndpoint" class="com.foo.FooEndpoint">
      	<constructor-arg ref="fooResponseMarshaller" />
      	<constructor-arg ref="fooRequestUnmarshaller" />
      </bean>
      <bean id="fooResponseMarshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
      	<property name="bindingName" value="JiBXbindingFoo" /
      	<property name="targetClass" value="com.foo.FooResponse" />
      </bean>
      <bean id="fooRequestUnmarshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
      	<property name="bindingName" value="JiBXbindingFoo" /
      	property name="targetClass" value="com.foo.FooRequest" />
      </bean>
      FooEndpoint extends org.springframework.ws.server.endpoint.AbstractMar shallingPayloadEndpoint

      Code:
      package com.foo;
      
      import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;
      
      public class FooEndpoint extends AbstractMarshallingPayloadEndpoint {
      
      	@Override
      	protected Object invokeInternal(Object requestObject) throws Exception {
      		FooRequest fooRequest = (FooRequest) requestObject;
      		FooResponse fooResponse = new FooResponse();
      		fooResponse.setResponse(fooRequest.getRequest());
      		return fooResponse;
      	}

      Code:
      public class FooRequest {
      	private String request;
      	
      	public String getRequest() {
      		return request;
      	}
      	
      	public void setRequest(String request) {
      		return request;
      	}
      }
      Code:
      public class FooResponse {
      	private String response;
      	
      	public String getResponse() {
      		return response;
      	}
      	
      	public void setResponse(String response) {
      		return response;
      	}
      }
      JiBX binding file: (jibx-binding.xml, for example)

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <binding name="JiBXbindingFoo">
      	<mapping name="FooRequest" class="com.foo.FooRequest" ordered="true">
      		<property name="request" field="request" />
      	</mapping>
      	<mapping name="FooResponse" class="com.foo.FooResponse" ordered="true">
      		<property name="response" field="response" />
      	</mapping>
      </binding>
      Note, if you use Eclipse and test with an embedded Tomcat server, you will need to add a Builder to your workspace so that every time you do a clean, the JiBX binding compiler will run automatically. If you use Maven, then this is easy to do. If interested I can post this as well

      Hope this helps
      Alan
      Last edited by Alan Stewart; Sep 1st, 2009, 12:00 AM.

      Comment


      • #4
        Hi Alan,

        How do you specify the marshaller and unmarshaller if you have multiple target classes?

        Is it possible to specify the contextPath as we do with JAXB2?

        Thanks,
        Sree

        Comment


        • #5
          I am using Jibx using maven. I was able to build successfully using maven pom.xml. But after deploying i am getting following error in log:
          MessageDispat E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed
          org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'getPlansEndpoint' defined in ServletContext resource [/WEB-INF/spring/ohsbrating-webservice-beans.xml]: Cannot resolve reference to bean 'getPlansMarshaller' while setting bean property 'marshaller'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'getPlansMarshaller' defined in ServletContext resource [/WEB-INF/spring/ohsbrating-webservice-beans.xml]: Invocation of init method failed; nested exception is org.jibx.runtime.JiBXException: Unable to access binding information for class com.uhc.ws.ohsbratingservice.model.GetPlansRespons e
          Make sure the binding has been compiled
          at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:329)
          at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:107)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1387)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1128)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:458)
          at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 95)
          at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:223)
          at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
          at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
          at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:628)
          at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:932)
          at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:479)
          at org.springframework.web.servlet.FrameworkServlet.c onfigureAndRefreshWebApplicationContext(FrameworkS ervlet.java:651)
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:5 99)
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:6 65)
          at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:518 )
          at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:459)
          at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:136)
          at javax.servlet.GenericServlet.init(GenericServlet.j ava:241)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.ini t(ServletWrapper.java:358)
          at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl .init(ServletWrapperImpl.java:169)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:739)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:502)
          at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl .handleRequest(ServletWrapperImpl.java:179)
          at com.ibm.ws.webcontainer.webapp.WebApp.handleReques t(WebApp.java:3935)
          at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequ est(WebGroup.java:276)
          at com.ibm.ws.webcontainer.WebContainer.handleRequest (WebContainer.java:931)
          at com.ibm.ws.webcontainer.WSWebContainer.handleReque st(WSWebContainer.java:1592)
          at com.ibm.ws.webcontainer.channel.WCChannelLink.read y(WCChannelLink.java:186)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleDiscrimination(HttpInboundLink.java:452)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleNewRequest(HttpInboundLink.java:511)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.processRequest(HttpInboundLink.java:305)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.ready(HttpInboundLink.java:276)
          at com.ibm.ws.tcp.channel.impl.NewConnectionInitialRe adCallback.sendToDiscriminators(NewConnectionIniti alReadCallback.java:214)
          at com.ibm.ws.tcp.channel.impl.NewConnectionInitialRe adCallback.complete(NewConnectionInitialReadCallba ck.java:113)
          at com.ibm.ws.tcp.channel.impl.AioReadCompletionListe ner.futureCompleted(AioReadCompletionListener.java :165)
          at com.ibm.io.async.AbstractAsyncFuture.invokeCallbac k(AbstractAsyncFuture.java:217)
          at com.ibm.io.async.AsyncChannelFuture.fireCompletion Actions(AsyncChannelFuture.java:161)
          at com.ibm.io.async.AsyncFuture.completed(AsyncFuture .java:138)
          at com.ibm.io.async.ResultHandler.complete(ResultHand ler.java:204)
          at com.ibm.io.async.ResultHandler.runEventProcessingL oop(ResultHandler.java:775)
          at com.ibm.io.async.ResultHandler$2.run(ResultHandler .java:905)
          at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1604)



          Can anybody help me out in this.

          Comment


          • #6
            This means that your classes have not been instrumented by the Jibx binder correctly.

            Comment

            Working...
            X