Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Response-Attachment/Saaj/Jaxb

  1. #1
    Join Date
    Mar 2009
    Posts
    18

    Default Response-Attachment/Saaj/Jaxb

    Hi,

    searched the web for hours, but didn't find a solution

    We use:
    - spring 3.0.5
    - spring ws 2.0
    - jaxb
    - saaj
    - java 1.6
    - tomcat 6.0.29
    - soapUI

    We want to add a xml file to the ws-response (or a zip file containing the xml File) but content seams to be inline.

    config:
    Code:
    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
    
    <util:list id="xsds">
    		<value>WEB-INF/xsd/info.xsd</value>
    ...
    </util:list>
    
    	<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="contextPath" value="xx.xx.ws.domain" />
    		<property name="schemas" ref="xsds"/>
    		<property name="mtomEnabled" value="true"/>
    	</bean>
    
    	<bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
    		<constructor-arg ref="jaxbMarshaller"/>
    	</bean>
    	
    	<bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
    		<property name="methodArgumentResolvers">
    			<list>
    				<ref bean="marshallingPayloadMethodProcessor"/>
    			</list>	
    		</property>
    		<property name="methodReturnValueHandlers">
    			<list>
    				<ref bean="marshallingPayloadMethodProcessor"/>
    			</list>
    		</property>
    	</bean>
    XSD:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://pms.dataconnect.ch/ws/schema/info"
    	xmlns:tns="http://pms.dataconnect.ch/ws/schema/info"
    	xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
    	elementFormDefault="qualified">
    
    	<element name="InfoResponse">
    		<complexType>
    			<sequence>
    				<element name="Info" minOccurs="0" maxOccurs="unbounded" >
    					<complexType>
    						<sequence>
    ...
    							<element name="File" type="base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
    						</sequence>
    					</complexType>
    				</element>
    			</sequence>
    		</complexType>
    	</element>
    </schema>
    --> generated objects and factory by xjc

    Endpoint:
    Code:
    @Endpoint
    public class InfoEndpoint
    {
    ...
    @PayloadRoot(localPart = REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI)
    @ResponsePayload
    public InfoResponse getInfo(@RequestPayload InfoRequest rafInfoRequest) throws Exception
    {		
    	ObjectFactory factory = new ObjectFactory();
    
    	InfoResponse response = factory.createInfoResponse();
    
            ...
            Info info = factory.createInfoResponseRAFInfo();
    
            File f = zip(clob);
    
            DataSource source = new FileDataSource(f);
    		
    	DataHandler handler = new DataHandler(source);
    		
    	info.setFile(handler);
    ...
    Response seen in soapUI: Attachments: (0), but inline:

    Code:
    ....
           <ns2:Info>
           ...
           <ns2:File>UEsDBBQACAAIAExi4AAAAAAAAAHAAAAc ... </ns2:RAF>
       </ns2:Info>
    </ns2:InfoResponse>
    Tried to debug:
    - marshall in org.springframework.oxm.jaxb.Jaxb2Marshaller is never called (why?)
    - Jaxb2AttachmentMarshaller in Jaxb2Marshaller is never called
    - AbstractJaxb2PayloadMethodProcessor.marshalToRespo nsePayload is called

    What am I doing wrong or what is missing, that the file is attached?

    Or:

    is ist possible to add a attachment at the endpoint manually as attachment without "xsd" and jaxb?

    Any help appreciated!
    Thanks in advance!

    mala

  2. #2

    Default

    Its is a jaxb bug.
    I have open a jira

    Solution: upgrade your jdk to the last version.

    Just to warn you that you will meet others issues like :
    - out of memory error with big files : google mtom spring
    - if the file is retrieve from the database, problem of transaction closed before it is used

    Have a nice day

  3. #3
    Join Date
    Mar 2009
    Posts
    18

    Question

    Hi,

    thanks mada for your help!

    I updated my JDK from 1.6_22 to 1.6_24 (Win 64bit), but no effect!


    Is there a workoround? Atach the file manually to the response at the endpoint without jaxb?
    Or may castor be the solution (any good example for attaching to the response?)

    Any help will be greatly appreciated..
    mala

    (I read about outOfMemory - my files are not that big (some KB)...)

  4. #4

    Default

    Ok let us the dichotomy search to restrict the origin of your problem.

    Download the spring ws source . there is a sample named Mtom using mtom. Try it without change and see if there is STILL a inline.

    if the answer is YES: then the problem is at 99% for me not about spring ws but concerns your version of jaxb because it workds perfectly in my computer.

    If it still doesnt work, try on an other computer with the same sample.

    Are you sur after downloading and installing the new jdk that your Eclipse or environnement variable still doesnt use the old one ? Just delete the old one to be sure.

    And yes you can add yourself the attachments to the soapMessage but it is painful. Just try to avoid it

    At last but not least your configuration is just to verbose, this will works too :
    Code:
    <util:list id="xsds">
    		<value>WEB-INF/xsd/info.xsd</value>
    ...
    </util:list>
    
    	<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="contextPath" value="xx.xx.ws.domain" />
    		<property name="schemas" ref="xsds"/>
    		<property name="mtomEnabled" value="true"/>
    	</bean>
    
    
    	
    	<bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"/>
    Last edited by mada; Mar 23rd, 2011 at 05:57 AM.

  5. #5
    Join Date
    Mar 2009
    Posts
    18

    Default

    Hi, thanks for your help!

    - yes, I deinstalled jdk 1.6.22; Java_Home is "_24"
    - I also build a war file of my project and deployed it in a tomcat outside eclipse
    - same project - other machine - same behaviour...

    I build and started mtom-server from spring-ws samples project.
    Via soupUI I sent a store request with an image attached and then I got the image back as a attachment (load request).
    seams, as my system is ok so far...

    then I tried your "last but not least" suggestion: no effect

    jaxb domain objects are build with jaxb-xjc 2.1.8 - may be thats a problem?

    perhaps there are wrong jar in my classpath?

    manifest entries:
    Code:
    ../../WebContent/WEB-INF/lib/antlr-2.7.6.jar 
    ../../WebContent/WEB-INF/lib/aopalliance-1.0.jar 
    ../../WebContent/WEB-INF/lib/aspectjweaver-1.5.4.jar
    ../../WebContent/WEB-INF/lib/commons-beanutils-1. 8.3.jar 
    ../../WebContent/WEB-INF/lib/commons-collections-3.2.1.jar 
    ../../WebContent/WEB-INF/lib/commons-dbcp.jar
    ../../WebContent/WEB-INF/lib/commons-digester-2.1.jar
    ../../WebContent/WEB-INF/lib/commons-lang-2.6.jar
    ../../WebContent/WEB-INF/lib/commons-logging-1.1.1.jar
    ../../WebContent/WEB-INF/lib/commons-pool-1.5.5.jar
    ../../WebContent/WEB-INF/lib/dom4j-1.6.1.jar
    ../../WebContent/WEB-INF/lib/ehcache-core-2.4.0.jar
    ../../WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar
    ../../WebContent/WEB-INF/lib/hibernate3.6.1.jar
    ../../WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar
    ../../WebContent/WEB-INF/lib/jstl-1.1.2.jar
    ../../WebContent/WEB-INF/lib/jta-1.1.jar
    ../../WebContent/WEB-INF/lib/log4j-1.2.14.jar
    ../../WebContent/WEB-INF/lib/ojdbc5-11.1.0.7.0.jar
    ../../WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar
    ../../WebContent/WEB-INF/lib/slf4j-log4j12-1.6.1.jar
    ../../WebContent/WEB-INF/lib/spring-aop-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-asm-3.0.5.RELEASE.jar 
    ../../WebContent/WEB-INF/lib/spring-beans-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-context-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-context-support-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-core-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-expression-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/sring-jdbc-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-orm-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-oxm-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-tx-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-web-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-webmvc-3.0.5.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-ws-core-2.0.0.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-ws-security-2.0.0.RELEASE.jar
    ../../WebContent/WEB-INF/lib/spring-xml-2.0.0.RELEASE.jar
    ../../WebContent/WEB-INF/lib/standard-1.1.2.jar
    ../../WebContent/WEB-INF/lib/wsdl4j-1.6.1.jar
    ../../WebContent/WEB-INF/lib/xmlsec-2.0.jar
    ../../WebContent/WEB-INF/lib/xws-security-3.0.jar

  6. #6

    Default

    "Jaxb domain objects are build with jaxb-xjc 2.1.8 - may be thats a problem?"


    I dont know but you should use the own available in your last jdk downloaded.
    So we are no sure that the problem is NOT about your machine because mtom-sample works.

    How do you generate the jaxb objects ?
    Try to use the jaxb maven plugin used in mtom sample & see if it is ok. NEVER generate them by hand, to much error prone!!
    Need help on Spring WS ? Do you want to shift gears and build the architecture of your spring ws with half of the price that will be for your company ? I have worked on Spring Ws 1,5 year at full time and build around80 WS with full dao testing and integration tests with Soapui with Maven 2 on hudson

  7. #7
    Join Date
    Mar 2009
    Posts
    18

    Default

    hi!

    I'm not that familiar with maven, so I'm useing ant:

    Code:
    	<target name="jaxb2-ws-domain-generation">
    		<xjc destdir="src" package="ch.xxxx.ws.domain" removeOldOutput="yes">
    			<schema dir="${xsd.dir}">
    				<include name="*.xsd" />
    				<exclude name="servicefault.xsd" />
    			</schema>
    		</xjc>
    	</target>
    changed generation to latest jaxb-version - no effect...

    OK, I'll try to generate the class with maven...

    mala
    Last edited by langmar; Mar 24th, 2011 at 07:43 AM.

  8. #8

    Default

    You seems to handle spring ws like a black box. But their source is available so why not try to dig into it ?


    Add a debug point in the class org.springframework.oxm.jaxb.Jaxb2Marshaller at:
    Code:
    	public void marshal(Object graph, Result result, MimeContainer mimeContainer) throws XmlMappingException {
    		try {
    			Marshaller marshaller = createMarshaller();
    			if (this.mtomEnabled && mimeContainer != null) {
    				marshaller.setAttachmentMarshaller(new Jaxb2AttachmentMarshaller(mimeContainer));
    			}
    			if (StaxUtils.isStaxResult(result)) {
    				marshalStaxResult(marshaller, graph, result);
    			}
    			else {
    				marshaller.marshal(graph, result);
    			}
    		}
    		catch (JAXBException ex) {
    			throw convertJaxbException(ex);
    		}
    	}
    at the line : this.mtomEnabled && mimeContainer != null

    Do the same thing in the public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException

    And see what happens.
    Need help on Spring WS ? Do you want to shift gears and build the architecture of your spring ws with half of the price that will be for your company ? I have worked on Spring Ws 1,5 year at full time and build around80 WS with full dao testing and integration tests with Soapui with Maven 2 on hudson

  9. #9
    Join Date
    Mar 2009
    Posts
    18

    Default

    hi mada,

    thanks for your endurance!

    generation by maven - no effect...



    I tried to debug my project as you mentioned:

    - un/marshall(...) in org.springframework.oxm.jaxb.Jaxb2Marshaller is never called

    - Jaxb2AttachmentMarshaller in Jaxb2Marshaller is never called

    - AbstractJaxb2PayloadMethodProcessor.marshalToRespo nsePayload is called

    setMtomEnabled(bool) --> calles vith "true" while startup


    If I debug the spring-ws tmom server marshal(...) is called...

    Where's my fault?

    Thanks in advance

  10. #10

    Default

    maybe it is a bug try the same configuration of Mtom sample with :
    Code:
        <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
            <constructor-arg ref="marshaller"/>
        </bean>
    intead of your Default....
    Need help on Spring WS ? Do you want to shift gears and build the architecture of your spring ws with half of the price that will be for your company ? I have worked on Spring Ws 1,5 year at full time and build around80 WS with full dao testing and integration tests with Soapui with Maven 2 on hudson

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •