Announcement Announcement Module
Collapse
No announcement yet.
SpringWs Attach soap messange Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SpringWs Attach soap messange

    Hey everybody,

    I'm new here so sorry if i make something wrong ! ( or write )
    Well I've trying to make a webservice call and have as answare a message with soap header appearing ! I was reading the spring documentation and i could make a call and have a answare but the soap header never appers, for example the photo atached.

    I really tried to get some examples in google but I couldn't....

    I use xmlbeans to generate the classes from a WSDL.

    This is my Spring xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:oxm="http://www.springframework.org/schema/oxm"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
    
     	
    	
    	<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
    	<!--
    	<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
    	    <property name="payloadCaching" value="true"/>
    	</bean>
    	-->
    	<bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />
    		
    	<!-- instanciando bean do WebService -->
    	<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    		<constructor-arg ref="messageFactory"/>
            <property name="defaultUri" value="http://192.168.10.245:40110/SegEngine/SegEngine"/>
    		<property name="marshaller" ref="marshaller"/>
    		<property name="unmarshaller" ref="marshaller"/>	
    	</bean>
    		
    </beans>
    My POM dependencies :

    Code:
     <dependencies>
      			<!-- SPRING -->
      	<dependency>
    		<groupId>org.springframework</groupId>
    		<artifactId>spring</artifactId>
    		<version>2.5.5</version>
    		<type>jar</type>
    	</dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>1.5.4</version>
        </dependency>
        <dependency>
    		<groupId>org.springframework</groupId>
    		<artifactId>spring-aspects</artifactId>
    		<version>2.5.5</version>
    	</dependency>
    	<dependency>
            <groupId>jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1</version>
        </dependency>
    	<dependency>
           <groupId>com.sun.xml.messaging.saaj</groupId>
           <artifactId>saaj-impl</artifactId>
           <version>1.3</version>
           <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.soap</groupId>
            <artifactId>saaj-api</artifactId>
            <version>1.3</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
    	 <groupId>xerces</groupId>
    	 <artifactId>xercesImpl</artifactId>
    	 <version>2.8.1</version>
    	</dependency>
    	<dependency>
    	 <groupId>xalan</groupId>
    	 <artifactId>xalan</artifactId>
    	 <version>2.7.0</version>
    	</dependency>
    	  </dependencies>
    and my java class:

    Code:
    package br.com.b2w.service.client;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.ws.WebServiceMessage;
    import org.springframework.ws.client.core.WebServiceMessageCallback;
    import org.springframework.ws.client.core.WebServiceTemplate;
    import org.springframework.ws.soap.SoapMessage;
    import org.springframework.ws.soap.addressing.client.ActionCallback;
    
    import com.b2W.seg.engine.service.StartDocument;
    import com.b2W.seg.engine.service.StartResponseDocument;
    import com.b2W.seg.engine.service.impl.StartResponseDocumentImpl;
    
    public class TestCallStartMarshelling {
    	
    	private WebServiceTemplate webServiceTemplate;
    	
       
    	public TestCallStartMarshelling() {
    		
    		ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath*:servicesContext.xml");
    
    		this.webServiceTemplate = (WebServiceTemplate) appContext.getBean("webServiceTemplate");
    		
    		this.callStart(null);
    		
    	}
    	
    	private StartResponseDocument callStart(StartDocument startDocument){
    				
    		WebServiceMessageCallback callBack = null;
    		Object d = null;
    		//d = webServiceTemplate.marshalSendAndReceive("http://192.168.10.245:40110/SegEngine/SegEngine",startDocument, callBack);
    		
    		d = webServiceTemplate.marshalSendAndReceive("http://192.168.10.245:40110/SegEngine/SegEngine",startDocument,new WebServiceMessageCallback() {
    
    	        public void doWithMessage(WebServiceMessage message) {
    	            ((SoapMessage)message).setSoapAction("http://192.168.10.245:40110/SegEngine/SegEngine");
    	        }
    	    });
    
    		 System.out.println(d.toString());  
    
    		 return null;
    	}
    	
    	
    	private StartDocument createStartDocument(){
    		StartDocument startDocument = StartDocument.Factory.newInstance();
    		
    		startDocument.addNewStart();
    		
    		System.out.println(startDocument.toString());
    
    		return startDocument;
    	}
    	
    	public static void main(String[] args) {
    		
    		new TestCallStartMarshelling();
    		
    		
    	}
    }
    It works but i never see the soap header, and i need it to make a secound call !!!

    Someone to help ????

    Thanks from Brazil
Working...
X