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

  • Attachments / MTOM

    Hi,

    I read that you support SwA attachments by casting WebServiceMessage to SoapMessage. Then operate on SoapMessage in the normal J2EE way. I guess I could create interceptors analogous to JAX-RPC handlers in J2EE. These handlers could operate on the SoapMessage while the implementation deals mainly with payload.

    Also, I saw that you will support MTOM with JAXB2. Does that mean that the JAXB endpoint binding is the first to support MTOM and that the other supported data bindings will eventually have support as well.

    Hopefully, you will have samples of how to manipulate MTOM attachments. Basically, you will have to give us a javax.activation.DataHandler for input attachments and we will have to give you a javax.activation.DataHandler for output attachments.

    Thanks.

  • #2
    Originally posted by TDean View Post
    Also, I saw that you will support MTOM with JAXB2. Does that mean that the JAXB endpoint binding is the first to support MTOM and that the other supported data bindings will eventually have support as well.
    That's the idea. I created an abstraction called MimeMarshaller, which can marshal a DataHandler or a byte[] to a MIME attachment.

    Originally posted by TDean View Post
    Hopefully, you will have samples of how to manipulate MTOM attachments. Basically, you will have to give us a javax.activation.DataHandler for input attachments and we will have to give you a javax.activation.DataHandler for output attachments.
    I'm not sure if I have time to create a sample, but at least you can look at the unit test code to see how it works.

    Comment


    • #3
      Hello,

      i have a web service that i want to return an attachment.
      i use jaxb2 and spring-ws- rc1.

      i try with 2 schemas:

      first:
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
              targetNamespace="http://www.qindel.com/padron"
              xmlns="http://www.qindel.com/padron"
              elementFormDefault="qualified"
              attributeFormDefault="unqualified">
      
        <xs:element name="RespuestaVolante" type="tipo_RespuestaVolante"/>
      
        ...
      
        <xs:complexType name="tipo_RespuestaVolante">
          <xs:sequence>
          <xs:element name="attfake" type="xs:base64Binary"/>
          </xs:sequence>
        </xs:complexType>
      this generate a byte [] attfake.

      the second
      Code:
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
              targetNamespace="http://www.qindel.com/padron"
              xmlns="http://www.qindel.com/padron"
              xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
      
        <xs:element name="RespuestaVolante" type="tipo_RespuestaVolante"/>
        ...
        <xs:complexType name="tipo_RespuestaVolante">
          <xs:sequence>
          <xs:element name="attfake" type="xs:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
          </xs:sequence>
        </xs:complexType>
      </xs:schema>
      this generate a DataHandler attfake.

      In the two cases the web service works and returns the same:
      Code:
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:RespuestaVolante xmlns:ns2="http://www.qindel.com/padron"><ns2:attfake>Sk9ERVIhISE=</ns2:attfake></ns2:RespuestaVolante></SOAP-ENV:Body></SOAP-ENV:Envelope>
      but not in an attachment!
      how configure it for returns the byte in an attachment?

      thanks in advance,
      CÚsar.

      Comment


      • #4
        I'll try and generate a sample that shows MTOM attachments soon.

        Comment


        • #5
          I've created that sample. It's called 'mtom' (quite a fitting name ), and has a JAX-WS client, so it's pretty interoperable.

          I came across a couple of bugs in the MTOM supports, so I fixed those as well. No wonder you couldn't make it work: sorry about that.

          The sample will be includes in the RC2 release, to be performed later this week.

          Comment


          • #6
            Hi, Arjen,

            Thank you for your sample, it is very helpful. One more question, if change to AxiomSoapMessageFactory, what are the dependencies? Thanks.

            Comment


            • #7
              My focus has been on doing SAAJ MTOM support, and so far I haven't had time to investigate Axiom's MTOM stuff. So, for now MTOM on Axiom might work, but I haven't tried it yet.

              Comment


              • #8
                Hello again,

                i think that i have mtom enable in web service , because log:
                Code:
                09 jul 2007 13:15:36,965 DEBUG org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint.marshalResponse(AbstractMarshallingPayloadEndpoint.java:147) Marshalling [javax.xml.bind.JAXBElement@1e9d0cc] to response payload 
                09 jul 2007 13:15:37,137 ERROR org.springframework.ws.server.endpoint.interceptor.AbstractValidatingInterceptor.handleResponseValidationErrors(AbstractValidatingInterceptor.java:206) XML validation error on response: cvc-type.3.1.2: Element 'ns2:attfake' is a simple type, so it must have no element information item [children]. 
                09 jul 2007 13:15:37,200 DEBUG org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:164) MessageDispatcher with name 'padron' sends response [------=_Part_0_21630945.1183979737137
                Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
                
                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:RespuestaVolante xmlns:ns2="http://www.qindel.com/padron"><ns2:url>http://fedorareg:9080/fedora/get/navreg:38/nav:FopServiceDef/xml2Pdf</ns2:url><ns2:attfake><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:f17f47ca-9033-49b9-b3f4-3b95830be82b%40www.qindel.com"/></ns2:attfake></ns2:RespuestaVolante></SOAP-ENV:Body></SOAP-ENV:Envelope>
                ------=_Part_0_21630945.1183979737137
                Content-Type: application/octet-stream
                Content-ID: <f17f47ca-9033-49b9-b3f4-3b[email protected]>
                
                QUE PASA!!!
                ------=_Part_0_21630945.1183979737137--] for request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:PeticionVolante xmlns:ns2="http://www.qindel.com/padron"><ns2:Documento>50200203N</ns2:Documento></ns2:PeticionVolante></SOAP-ENV:Body></SOAP-ENV:Envelope>]
                but my client doesn't work:
                Code:
                public class PadronMarshallClient extends WebServiceGatewaySupport {
                  ...
                  JAXBElement response = (JAXBElement)getWebServiceTemplate().marshalSendAndReceive(request);
                  respuestaVolante = (TipoRespuestaVolante)response.getValue();
                  byte []attfake = respuestaVolante.getAttfake();
                  logger.info("attfake: " + new String(attfake));
                  logger.info("attfake.length(): " + attfake.length);
                the others elements of the response has values, but attfake not, is empty.
                Code:
                  <bean id="padronMarshallClient" class="com.qindel.padron.ws.client.PadronMarshallClient">
                    <property name="defaultUri" value="${padron.ws.url}"/>
                    <property name="marshaller" ref="jaxbMarshaller"/>
                    <property name="unmarshaller" ref="jaxbMarshaller"/>
                  </bean>
                
                  <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                    <description>
                        The validating JAXB Marshaller is used by the peticionVolanteMarshallEndpoint to unmarshal XML to objects and
                        vice-versa.
                    </description>
                    <property name="mtomEnabled" value="true"/>
                    <property name="contextPath" value="com.qindel.padron.ws.xml.jaxb"/>
                  </bean>
                what's wrong with my client configuration?

                thank in advance,
                CÚsar.

                Comment


                • #9
                  I think the client-side support for JAXB2 MTOM marshalling is not working well. Could you create a JIRA issue for this please?

                  Comment


                  • #10
                    hello,

                    JIRA issue:
                    http://opensource.atlassian.com/proj...browse/SWS-156

                    thanks.

                    Comment


                    • #11
                      Originally posted by Arjen Poutsma View Post
                      I've created that sample. It's called 'mtom' (quite a fitting name ), and has a JAX-WS client, so it's pretty interoperable.
                      Are you sure that:

                      Code:
                      17   	     <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                      18 	        <property name="contextPath" value="org.springframework.ws.samples.mtom.schema"/>
                      19 	    </bean>
                      in /samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml is correct?

                      It works, but this won't create attachment (just will send base64 encoded content).

                      As it is mtom example i think that mtomEnabled property should be set to true. Default value is false.

                      Comment


                      • #12
                        Oops. You are right: the mtomEnabled property should be set to false. Will be fixed in 1.0.1.

                        Comment


                        • #13
                          I think it should be set to true :-)

                          Comment


                          • #14
                            Right, set it to true. It has been a busy week!

                            Comment


                            • #15
                              Originally posted by Arjen Poutsma View Post
                              My focus has been on doing SAAJ MTOM support, and so far I haven't had time to investigate Axiom's MTOM stuff. So, for now MTOM on Axiom might work, but I haven't tried it yet.
                              How about now ? Ive just try to add a AxiomSoapMessageFactory in spring-sample-mtom with jaxb and the attachement send from the AxiomMtomClient of the mtom-sample is received inline (and outofmemory occur if the file is to big). WIthout AxiomSoapMessageFactory, it is received as an attachment according to the SoapEnvelopeLoggingInterceptor

                              In fact im looking for a better way to receive attachment without trying to dig in the messageContext & be able to use the benefits of Jaxb with heavy attachement (more than 10mo).


                              Im really loking for a sample able to send & receive a file of 10 mo and more with jax-ws & spring ws. (the mtom sample is not the one) I feel desperate
                              Last edited by mada; Aug 29th, 2010, 01:06 PM.

                              Comment

                              Working...
                              X