Hello all,

I am trying to create a REST web service which accepts HTTP POST request
with a binary attachment(an audio file) and an XML document .

I am trying to define the interface in such a way that the binary file is
received as an attachment/header in Camel message and the XML document as
the body.

So far, I have tried to define the parameters as @Multipart for receiving
attachments. Here is the interface :

*Class RestReceive*

    @POST
    @Path("/")
    public Response receive(@Multipart(type = "application/octet-stream",
value = "audio", required=false) byte[] audio,
                                        @Multipart(type = "text/xml", value
= "description") String description) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

*cxf configuration:*

<cxf:rsServer id="receive-rest-server"
                  address="/contact"
                  serviceClass="RESTReceive"/>


*Route defintion:*

<route id="receive-rest">
            <from
uri="cxfrs:bean:receive-rest-server?bindingStyle=SimpleConsumer"/>

......
.......


The SimpleConsumer binding makes it easier to access the input as headers.
However, the problem remains that the client has to send the audio file as
well as the xml document as attachment.

I tried the alternate definition as following:

    @POST
    @Path("/")
    public Response receive(@Multipart(type = "application/octet-stream",
value = "audio", required=false) byte[] audio,
                                        String description) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

I was expecting that the client can send the audio file as attachment as
text document as body.

But that didn't work. It failed with method does not exist.


Can somebody suggest a way to do what I am trying to achieve ; be able to
receieve audio file as header and xml as body of the HTTP POST request.

Thanks for any suggestions.

Reply via email to