java metro framework - mtom return always attachment witi content-type = "image/png" -


in example of soap mtom optimization i've realized project on tomcat 7, metro (glassfish) in i've got:

xsd

<xs:element name="retrievepicture" type="tns:retrievepicture"/> <xs:complextype name="retrievepicture">   <xs:sequence>     <xs:element name="inimagenumber" type="xs:int"/>   </xs:sequence> </xs:complextype>  <xs:element name="retrievepictureresponse" type="tns:jpegpicturetype"/> <xs:simpletype name="jpegpicturetype"     xmime:expectedcontenttypes="image/jpeg">     <xs:restriction base="xs:base64binary" /> </xs:simpletype> 

wsdl

<definitions ... >     <wsp:policy         wsu:id="picturemanagerportbinding_mtom_policy-picturemanagerportbinding_mtom_policy">         <ns1:optimizedmimeserialization             xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"             wsp:optional="true" />     </wsp:policy>     <types>         <xsd:schema>             <xsd:import namespace="http://service.ivan.com/" schemalocation="picturemanagerservice_schema1.xsd"/>         </xsd:schema>     </types>     <message name="retrievepicture">         <part name="parameters" element="tns:retrievepicture" />     </message>     <message name="retrievepictureresponse">         <part name="parameters" element="tns:retrievepictureresponse" />     </message>     <porttype name="picturemanager">         <operation name="retrievepicture">             <input                 wsam:action="http://service.ivan.com/picturemanager/retrievepicturerequest"                 message="tns:retrievepicture" />             <output                 wsam:action="http://service.ivan.com/picturemanager/retrievepictureresponse"                 message="tns:retrievepictureresponse" />         </operation>     </porttype>     <binding name="picturemanagerportbinding" type="tns:picturemanager">         <wsp:policyreference             uri="#picturemanagerportbinding_mtom_policy-picturemanagerportbinding_mtom_policy" />         <soap:binding transport="http://schemas.xmlsoap.org/soap/http"             style="document" />         <operation name="retrievepicture">         ...         </operation>     </binding>     <service name="picturemanagerservice">         ...     </service> </definitions> 

sei

@webservice(wsdllocation="web-inf/wsdl/picturemanagerservice.wsdl") @mtom public class picturemanager {     ....     @webmethod(operationname = "retrievepicture")     public image retrievepicture(             @webparam(name = "inimagenumber") final int inimagenumber) {         java.awt.image theimage = null;         //logic return image according request         return theimage;     } } 

my project consist of download jpeg image according of request. in soapui following raw response:

http/1.1 200 ok server: apache-coyote/1.1 content-type: multipart/related; start="<rootpart*c069e1e8-2a0a-4ef7-8270-19bda938c27d@example.jaxws.sun.com>"; type="application/xop+xml"; boundary="uuid:c069e1e8-2a0a-4ef7-8270-19bda938c27d"; start-info="text/xml" transfer-encoding: chunked date: wed, 03 jun 2015 08:03:55 gmt  --uuid:c069e1e8-2a0a-4ef7-8270-19bda938c27d content-id: <rootpart*c069e1e8-2a0a-4ef7-8270-19bda938c27d@example.jaxws.sun.com> content-type: application/xop+xml;charset=utf-8;type="text/xml" content-transfer-encoding: binary  <?xml version='1.0' encoding='utf-8'?><s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:body><ns2:retrievepictureresponse xmlns:ns2="http://service.ivan.com/"><return><xop:include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:deba19db-0a7f-4367-82c3-b466e22f31fd@example.jaxws.sun.com"/></return></ns2:retrievepictureresponse></s:body></s:envelope> --uuid:c069e1e8-2a0a-4ef7-8270-19bda938c27d content-id: <deba19db-0a7f-4367-82c3-b466e22f31fd@example.jaxws.sun.com> content-type: image/png content-transfer-encoding: binary 

the problem content type "image/png" wrong have expected "image/jpeg"

as had similar issue, don't think snippet generate datahandler:

<xs:simpletype name="jpegpicturetype"     xmime:expectedcontenttypes="image/jpeg">     <xs:restriction base="xs:base64binary" /> </xs:simpletype> 

i'am still trying find out why, meanwhile can same me , think too. use directly element retrievepictureresponse instead of working xs:simpletype, can use code :

<xs:element name="retrievepictureresponse" type="xs:base64binary"      xmime:expectedcontenttypes="image/jpeg" /> 

Comments