cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Consuming multi-part/mixed
Date Thu, 30 Jul 2015 16:52:14 GMT
Multipart annotation references application/json, so I guess it can be 
referenced too, though WADL says that representation parameters are 
simple ones. On the other hand WADL describing multipart is in itself 
quite undefined so may be we can indeed refer to complex parameters...

Sergey
On 30/07/15 19:45, Sergey Beryozkin wrote:
> Hi Benson
> I see WADLGenerator restricting that only simple or InputStream types
> are recognized as multipart parameters, I can deal with it next week
> once I got back, though the best you'll get is a WADL request
> representation fragment with two parameters of type xs:anyType in this case
>
> Cheers, Sergey
> On 29/07/15 21:07, Benson Margulies wrote:
>> <application xmlns="http://wadl.dev.java.net/2009/02"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>> <grammars/>
>> <resources base="http://192.168.59.103:8181/cxf/annotator">
>> <resource path="/">
>> <resource path="annotate">
>> <method name="POST">
>> <request>
>> <representation mediaType="multipart/mixed">
>> <param name="text" style="query" type="xs:anyType"/>
>> </representation>
>> </request>
>> <response>
>> <representation mediaType="application/json"/>
>> <representation mediaType="application/x-jackson-smile"/>
>> </response>
>> </method>
>> </resource>
>> <resource path="annotatePlain">
>> <method name="POST">
>> <request>
>> <representation mediaType="text/plain">
>> <param name="request" style="plain" type="xs:string"/>
>> </representation>
>> </request>
>> <response>
>> <representation mediaType="application/json"/>
>> </response>
>> </method>
>> </resource>
>> </resource>
>> </resources>
>> </application>
>>
>> On Wed, Jul 29, 2015 at 2:07 PM, Benson Margulies
>> <benson@basistech.com> wrote:
>>> Here's the perplexing wadl...
>>>
>>> On Wed, Jul 29, 2015 at 2:03 PM, Benson Margulies
>>> <benson@basistech.com> wrote:
>>>> The WADL for this shows only one parameter. Did I miss something?
>>>>
>>>>
>>>> @POST
>>>> @Consumes("multipart/mixed")
>>>> @Produces({"application/json", "application/x-jackson-smile"})
>>>> @Path("annotate")
>>>> public Response annotate(
>>>>      @Multipart(value = "options", type = "application/json")
>>>>      Map<String, String> options,
>>>>      @Multipart(value = "text") InputStream text) throws IOException,
>>>> RosetteException {
>>>>
>>>>      final ObjectMapper mapper = getMapper();
>>>>      AnnotatedText inputText = mapper.readValue(text,
>>>> AnnotatedText.class);
>>>>      final AnnotatedText result =
>>>> pipeline.createAnnotator().annotate(inputText);
>>>>
>>>>      StreamingOutput stream = new StreamingOutput() {
>>>>          @Override
>>>>          public void write(OutputStream os) throws IOException,
>>>> WebApplicationException {
>>>>              mapper.writeValue(os, result);
>>>>          }
>>>>      };
>>>>      return Response.ok(stream).build();
>>>> }
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message