Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch and Jaxb Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch and Jaxb

    Hello,
    I would like to use Jaxb 2 with Spring Batch 2.0.0. Does anybody has some experience with that?
    I'm using the marshaller in the following way:

    Code:
        <bean id="myMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="contextPath" value="org.myapp.xml"/>
        </bean>
    Which dependences do I need with Spring Batch 2.0.0? Actually I saw the following:
    - spring-xml-1.5.7
    - spring-oxm-1.5.7
    - spring-oxm-tiger-1.5.7
    - Jaxb2-api-2.1
    - jaxb2-impl-2.1

    Is it OK to use the following version of the above libraries with Jaxb2 or better to use spring-xml-1.5.5 and spring-oxm-1.5.5?
    THANK YOU!

  • #2
    Spring and JAXB

    We use JAXB artifacts in our SB integrations.

    Re: Dependencies include see attached image:

    Here's the code fragments form our application-context.xml

    Code:
                    <step id="step2" next="step3">
    		    <tasklet transaction-manager="transactionManager">
    			     <chunk reader="itemReader" writer="sfdcWriter"
    			      commit-interval="200" />					
    			</tasklet>
    		</step>
    ......
    
    	<!-- Bean for Custom Sfdc Writer that performs webservice call to Sfdc -->
        <beans:bean id="sfdcWriter" class="domain.SfdcWriter">
            <beans:property name="defaultUri" value="https://test.salesforce.com/services/Soap/c/16.0"/>
            <beans:property name="marshaller" ref="marshaller"/> 
            <beans:property name="unmarshaller" ref="marshaller"/> 
            <beans:property name="messageFactory" ref="messageFactory" />
        </beans:bean>
    
        <beans:bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">  
             <beans:property name="classesToBeBound">  
                 <beans:list>  
                    <beans:value>sfdc.enterprise.api.Login</beans:value>
                    <beans:value>sfdc.enterprise.api.LoginResponse</beans:value>  
                    <beans:value>sfdc.enterprise.api.Upsert</beans:value>   
                    <beans:value>sfdc.enterprise.api.UpsertResponse</beans:value>     
                 </beans:list>  
             </beans:property>  
         </beans:bean>
    Where the sfdc.enterprise.api.* are JAXB generated POJO's in our case generate from the Salesforce.COM enterprise.wsdl using JAXB xjc for wsdl to java.

    In the custom sfdcWriter marshling code frag's are:

    Code:
      private UpsertResponse marshalWithNewSoapHeader(Upsert o, final String sessionID) throws Exception{
    			
    		  // method uses an anonymous inner class to create apply the call back before sending
    		  // this is done to set the Session Soap Header ID
    				UpsertResponse upsertResponse = (UpsertResponse)getWebServiceTemplate().marshalSendAndReceive(o, new WebServiceMessageCallback() {
    
                    public void doWithMessage(WebServiceMessage message) 
    		        throws IOException {
                    	
    			         OMFactory factory = OMAbstractFactory.getOMFactory();
    			         OMNamespace sf = factory.createOMNamespace("urn:enterprise.soap.sforce.com","urn");
    			         OMElement sessionHeader = factory.createOMElement("SessionHeader", sf);
    			         OMElement sessionIdElement = factory.createOMElement("sessionId", sf);
    			         sessionIdElement.setText(sessionID);
    			         sessionHeader.addChild(sessionIdElement);
    			         SOAPHeader header =  ((AxiomSoapMessage)message).getAxiomMessage().getSOAPEnvelope().getHeader();
    			         header.addChild(sessionHeader);
    
    		 
                    }//end doWithMessage
                }//end getWebserviceTemplate implementing WebServiceMessageCallback
    		    ); //end getWebserviceTemplate
    			return upsertResponse;
    		}//end method
    Hope this helps...
    Last edited by james nuzzo; Jul 9th, 2009, 09:44 PM. Reason: spelling error

    Comment

    Working...
    X