Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-2706

Unable to unmarshall attachment parts where the type is 'application/octet-stream'

    XMLWordPrintable

Details

    Description

      Based on the following WSDL sections: -

      <message name="messageInput">
      <part name="request" element="s:InputRequest"/>
      <part name="attach1" type="xsd:string"/>
      <part name="attach2" type="xsd:base64Binary"/>
      </message>

      <message name="messageOutput">
      <part name="response" element="s:OutputResponse"/>
      <part name="attach1" type="xsd:string"/>
      <part name="attach2" type="xsd:base64Binary"/>
      </message>

      <binding name="SwaTestSoapBinding1" type="tns:SwaTest1">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

      <operation name="echoMultipleAttachments">
      <soap:operation/>
      <input>
      <mime:multipartRelated>
      <mime:part>
      <soap:body parts="request" use="literal"/>
      </mime:part>
      <mime:part>
      <mime:content part="attach1" type="application/octet-stream"/>
      </mime:part>
      <mime:part>
      <mime:content part="attach2" type="application/octet-stream"/>
      </mime:part>
      </mime:multipartRelated>
      </input>
      <output>
      <mime:multipartRelated>
      <mime:part>
      <soap:body parts="response" use="literal"/>
      </mime:part>
      <mime:part>
      <mime:content part="attach1" type="application/octet-stream"/>
      </mime:part>
      <mime:part>
      <mime:content part="attach2" type="application/octet-stream"/>
      </mime:part>
      </mime:multipartRelated>
      </output>
      </operation>
      </binding>

      JBossWS can send messages without problem but unmarshalling the messages results in the following error: -

      Caused by: javax.xml.soap.SOAPException: javaType [[B] is not assignable from attachment content: java.io.ByteArrayInputStream
      at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:248)

      The reason is because a DataHandler is used to wrap the attachment part, the data handler is passed the attachment along with the content type 'application/octet-stream' as this is not related to a specific type the call to getContent() on the DataHandler within EndpointInvocation returns an InputStraem for the attachment - this is not assignable to the expected Java type.

      The transformPayloadValue method in EndpointInvocation requires an additional step to take the InputStream and convert it to the expected Java type.

      Attachments

        Issue Links

          Activity

            People

              darran.lofthouse@redhat.com Darran Lofthouse
              darran.lofthouse@redhat.com Darran Lofthouse
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: