Announcement Announcement Module
No announcement yet.
JiBX Marshaller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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,

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



    • #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:
      <bean id="fooEndpoint" class="">
      	<constructor-arg ref="fooResponseMarshaller" />
      	<constructor-arg ref="fooRequestUnmarshaller" />
      <bean id="fooResponseMarshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
      	<property name="bindingName" value="JiBXbindingFoo" /
      	<property name="targetClass" value="" />
      <bean id="fooRequestUnmarshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
      	<property name="bindingName" value="JiBXbindingFoo" /
      	property name="targetClass" value="" />
      FooEndpoint extends shallingPayloadEndpoint

      public class FooEndpoint extends AbstractMarshallingPayloadEndpoint {
      	protected Object invokeInternal(Object requestObject) throws Exception {
      		FooRequest fooRequest = (FooRequest) requestObject;
      		FooResponse fooResponse = new FooResponse();
      		return fooResponse;

      public class FooRequest {
      	private String request;
      	public String getRequest() {
      		return request;
      	public void setRequest(String request) {
      		return request;
      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)

      <?xml version="1.0" encoding="UTF-8"?>
      <binding name="JiBXbindingFoo">
      	<mapping name="FooRequest" class="" ordered="true">
      		<property name="request" field="request" />
      	<mapping name="FooResponse" class="" ordered="true">
      		<property name="response" field="response" />
      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
      Last edited by Alan Stewart; Sep 1st, 2009, 12:00 AM.


      • #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?



        • #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 e
          Make sure the binding has been compiled
          at nitionValueResolver.resolveReference(BeanDefinitio
          at nitionValueResolver.resolveValueIfNecessary(BeanDe
          at AutowireCapableBeanFactory.applyPropertyValues(Abs
          at AutowireCapableBeanFactory.populateBean(AbstractAu
          at AutowireCapableBeanFactory.doCreateBean(AbstractAu
          at AutowireCapableBeanFactory.createBean(AbstractAuto
          at BeanFactory$1.getObject( 95)
          at ingletonBeanRegistry.getSingleton(DefaultSingleton
          at BeanFactory.doGetBean( )
          at BeanFactory.getBean(
          at istableBeanFactory.preInstantiateSingletons(Defaul
          at ationContext.finishBeanFactoryInitialization(Abstr
          at ationContext.refresh(AbstractApplicationContext.ja va:479)
          at org.springframework.web.servlet.FrameworkServlet.c onfigureAndRefreshWebApplicationContext(FrameworkS
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext( 99)
          at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext( 65)
          at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext( )
          at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(
          at it(
          at javax.servlet.GenericServlet.init(GenericServlet.j ava:241)
          at t(
          at .init(
          at dleRequest(
          at dleRequest(
          at .handleRequest(
          at t(
          at est(
          at (
          at st(
          at y(
          at nk.handleDiscrimination(
          at nk.handleNewRequest(
          at nk.processRequest(
          at nk.ready(
          at adCallback.sendToDiscriminators(NewConnectionIniti
          at adCallback.complete(NewConnectionInitialReadCallba
          at ner.futureCompleted( :165)
          at k(
          at Actions(
          at .java:138)
          at oop(
          at$ .java:905)
          at$ ava:1604)

          Can anybody help me out in this.


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