At times, we require multipart representation in request/response web services. We need to create custom MessageBodyReader<T>
and MessageBodyWriter<T>
implementation to support the multipart feature in our application. For this, we need to register MultiPartFeature
on the client and server sides. Look at the following example:
Server side:
public class UsingResourceConfig extends ResourceConfig { public UsingResourceConfig() { packages("com.chapter4.multipart") .register(MultiPartFeature.class); } }
Here, we registered
MultiPartFeature
at the time of application loading. This feature needs to be registered to provide the marshalling and unmarshalling of data on the server side.@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public String post( @FormDataParam("part") String part, @FormDataParam("part") FormDataContentDisposition d) { return part + ":" + d.getFileName(); }
Copyright © 2014 Oracle and/or its affiliates....