WSDL 1.1

<types>
   <xsd:schema
      targetNamespace='http://www.example.org/'>
      <xsd:element name="Photo" type='xsd:binary' />
   </xsd:schema>
</types>

<portType name="imageInterface">
    <operation name="getImage">
        <input name="getImageInput" />
        <output name="getImageOutput"
                   body='Photo'/>
    </operation>
</interface>

<binding name="imageHTTPBinding" type="imageInterface">
    <http:binding verb="GET"/>
    <operation name="getImage">
        <http:operation location=""/>
         <input />
         <output>
             <mime:content type="image/jpeg"/>
           (assuming we only use
             the content of the Photo element)
         </output>
    </operation>
</binding>

Generated code

with WSDL 1.1, based on the information available in the portType:

public byte[] getImage();

Our goal:

public java.awt.Image getImage();

Moving up: interface

<interface name="imageInterface">
    <operation name="getImage">
        <input name="getImageInput"/>
        <output name="getImageOutput"
                   body='Photo' mediaType='image/jpeg'/>
    </operation>
</interface>

Note: Arthur made a proposal on how to add mime type on the message element, but message has been removed from WSDL 1.2.

Moving up: XML Schema

Scope of solutions

  1. Schema extension (PASWA)
  2. Schema type extension
  3. Schema annotations
  4. Schema notations
  5. URIs

Note: Mark made some proposals on how to add media type in XML Schemas.

PASWA (1/3)

WSDL definitions:

<xsd:schema
      xmlns:xmime='http://schemas.xmlsoap.org/2003/04/xmime'
      targetNamespace='http://www.example.org/'>
  <xsd:element name="Photo" type='xmime:Binary'
        xmime:Accept='image/jpeg, image/gif;q=0.5'/>
</xsd:schema>

Note: the example above presumes the following definition:

<xsd:simpleType name='Binary'>
      <xsd:restriction base='xsd:base64Binary'/>
    </xsd:simpleType>

PASWA (2/3)

SOAP extensions:

<Photo xmime:MediaType='image/gif' >
        /aWKKapGGyQ=
</Photo>

PASWA (3/3)

Schema type extension (1/3)

WSDL definitions:

<xsd:schema
   targetNamespace='http://www.example.org/'
   xmlns:image='http://iana.org/mime/image'>
   <xsd:import namespace='http://iana.org/mime/image'/>
   <xsd:element name="Photo"
       type='okImagesT' />
   <xsd:simpleType name='okimagesT'>
      <xsd:union memberTypes='image:jpeg image:gif'/>
   </xsd:simpleType>
</schema>

Note: the example above presumes the following definition:

<xsd:schema targetNamespace='http://iana.org/mime/image'>
    <xsd:simpleType name='jpeg'>
      <xsd:restriction base='xsd:base64Binary'/>
    </xsd:simpleType>

    <xsd:simpleType name='gif'>
      <xsd:restriction base='xsd:base64Binary'/>
    </xsd:simpleType>
</xsd:schema>

Schema type extension (2/3)

no SOAP extensions

<Photo
    xmlns:image='http://iana.org/mime/image'
    xsi:type='image:gif' >
        /aWKKapGGyQ=
</Photo>
<Document
    xmlns:application='http://iana.org/mime/application'
    xsi:type='application:plhsoft' >
        /aWKKapGGyQ=
</Document>

Schema type extension (3/3)

Schema annotations (1/2)

WSDL definitions:

<xsd:schema
   targetNamespace='http://www.example.org/'>

   <xsd:element name="Photo"
       type='xsd:base64Binary'>
      <xsd:annotation>
          <mime:content types="image/jpeg image/gif"/>
      </xsd:annotation>
   </element>
</schema>

Schema annotations (2/2)

SOAP extensions:

<Photo xmime:MediaType='image/gif' >
        /aWKKapGGyQ=
</Photo>

Schema notations (1/2)

WSDL definitions:

<xsd:schema
   targetNamespace='http://www.example.org/'>

  <xs:notation name="jpeg"
             public="image/jpeg" system='http://iana.org/mime/image/jpeg'/>

  <xs:element name="Photo">
   <xs:complexType>
    <xs:simpleContent>
     <xs:extension base="xs:base64Binary">
      <xs:attribute name="pictype">
       <xs:simpleType>
        <xs:restriction base="xs:NOTATION">
         <xs:enumeration value="jpeg"/>
         <xs:enumeration value="png"/>
           . . .
        </xs:restriction>
       </xs:simpleType>
      </xs:attribute>
     </xs:extension>
    </xs:simpleContent>
   </xs:complexType>
  </xs:element>
</schema>

Schema notations (2/2)

SOAP:

<Photo pictype='jpeg' >
        /aWKKapGGyQ=
</Photo>

URIs

http://www.w3.org/2001/tag/2002/01-uriMediaType-9.html

Should we address language negociation?

<xsd:schema targetNamespace='http://example.org/lang'>
    <xsd:element name='myText'>
      <xsd:simpleType>
        <xsd:restriction base='xsd:string' lang:languages='en cs'/>
      </xsd:simpleType>
    </xsd:element>
</xsd:schema>
<myText xml:lang='en' >
        The sky is blue
</myText>