cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Fiala" <mod...@fwd.at>
Subject Re: JAXRS How to define/use Multiparts with Json + xs:base64Binary
Date Thu, 18 Aug 2016 14:21:33 GMT
p.s. a basic multipart like

<representation mediaType="multipart/form-data" />

works, but then I only get the generic MultipartBody generated without 
any hint to the client how to assemble it correctly.

Best regards,
Johannes


Am 18.08.2016 um 16:13 schrieb J. Fiala:
> Hello,
>
> I defined a Multipart in the WADL (I'd like to use a multipart with 
> both json data + binary data):
>
> <resource path="/createMultipart">
>                 <method name="POST">
>                     <request>
>                         <param name="name" style="query" 
> type="xs:string" required="true"/>
>                         <representation mediaType="application/json" 
> element="mytypes:CreateMultipartRequestType"/>
>                     </request>
>                     <response status="200">
>                         <representation mediaType="application/json" 
> element="xs:string"/>
>                     </response>
>                 </method>
>             </resource>
>
> <xs:complexType name="CreateMultipartRequestType">
>         <xs:sequence>
>             <xs:element name="requestModel" 
> type="mytypes:CreateRequestType" />
>             <xs:element name="payload" type="xs:base64Binary" 
> xmime:expectedContentTypes="application/octet-stream"/>
>         </xs:sequence>
>     </xs:complexType>
>
> <xs:complexType name="CreateRequestType">
>         <xs:sequence>
>             <xs:element minOccurs="1" name="description" 
> type="xs:string" />
> </xs:sequence>
>
> </xs:complexType>
>
> The generated Java code looks fine:
>
> @POST
>     @Consumes("application/json")
>     @Produces({"application/json" })
>     @Path("/createMultipart")
>     String postCreateMultipart(@QueryParam("name") String name, 
> CreateRequestType createRequestType);
>
> public class CreateMultipartRequestType {
>
>     @XmlElement(required = true)
>     @NotNull
>     @Valid
>     protected CreateRequestType requestModel;
>     @XmlElement(required = true)
>     @XmlMimeType("application/octet-stream")
>     @NotNull
>     protected DataHandler payload;
>
> }
>
> However, when I try to invoke the service using JacksonProvider, I get:
>
> WARNING: Interceptor for {http://myns/}MyResource has thrown 
> exception, unwinding now
> org.apache.cxf.interceptor.Fault: No message body writer has been 
> found for class at.hello.CreateMultipartRequestType, ContentType: 
> application/json
>
> Any idea how I have to specify the Multipart in the WADL to get it 
> working?
>
> Best regards,
> Johannes
>
>
>


Mime
View raw message