<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>
with WSDL 1.1, based on the information available in the portType:
public byte[] getImage();
Our goal:
public java.awt.Image getImage();
<interface name="imageInterface"> <operation name="getImage"> <input name="getImageInput"/> <output name="getImageOutput" body='Photo' mediaType='image/jpeg'/> </operation> </interface>
@mediaType
cannot only be applied to
@headers
.
Note: Arthur made a proposal
on how to add mime type on the message
element, but
message
has been removed from WSDL 1.2.
Scope of solutions
Note: Mark made some proposals on how to add media type in XML Schemas.
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>
SOAP extensions:
<Photo xmime:MediaType='image/gif' > /aWKKapGGyQ= </Photo>
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>
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>
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>
SOAP extensions:
<Photo xmime:MediaType='image/gif' > /aWKKapGGyQ= </Photo>
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>
SOAP:
<Photo pictype='jpeg' > /aWKKapGGyQ= </Photo>
<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>