Writing the WSDL extensions for SOAP messages with attachments

 

Usage scenario

The following WSDL illustrates a simple operation that has one attachment called attch :

<binding name="MyBinding" type="tns:abc" >
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="MyOperation">
    <soap:operation soapAction=""/>
    <input>
      <mime:multipartRelated>
        <mime:part>
          <soap:body parts="part1 part2 ..." use="encoded" namespace="http://mynamespace"
            encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
        </mime:part>
        <mime:part>
          <mime:content part="attch" type="text/html"/>
        </mime:part>
      </mime:multipartRelated>
    </input>
  </operation>
</binding>

Note:

  • There must be a part (in this example attch ) on the message for the operation (in this example MyOperation ). There can be other input parts to MyOperation that are not attachments.

  • In the binding input there must either be a <soap:body tag or a <mime:multipartRelated tag, but not both.

  • For MIME messages, the soap:body is inside a mime:part . There may be one mime:part that contains a soap:body in the binding input and that must not contain a mime:content as well, because a content type of text/xml is assumed for the soap:body .

  • There can be multiple attachments in a MIME message, each described by a mime:part .

  • Each mime:part (that is not a soap:body ) contains a mime:content that describes the attachment itself. The type attribute inside the mime:content is not checked or used by the gateway. It is there to suggest to the application using the gateway what the attachment contains. Multiple mime:contents inside a single mime:part means that the backend service will expect a single attachment with a type specified by one of the mime:contents inside that mime:part .

  • The parts="..." attribute inside the soap:body is assumed to contain the names of all the SOAP parts in the message, but not the attachment parts. If there are only attachment parts, then specify parts="" (empty string). If you omit the parts attribute altogether, then the gateway assumes ALL parts including the attachments - which means the attachments will appear twice.

In your WSDL you might have defined a schema for the attachment (for instance as a binary[] ). Whether or not you have done this, the gateway silently ignores this mapping and treats the attachment as a Data Handler .

Unreferenced attachments need not be mentioned in the WSDL bindings at all.


SOAP messages with attachments - a definition
Passing SOAP messages with attachments through the Web services gateway

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.