users@jersey.java.net

Re: header response code 415

From: guilhem legal <guilhem.legal_at_geomatys.fr>
Date: Fri, 15 Feb 2008 09:50:36 +0100

Sorry it was my bad, I was waiting for "text/xml" MIME type but in fact
i received "application/xml".

thanks for your help.
Guilhem Legal

Marc Hadley a écrit :
> Hmm, my guess would be that the browser request is taking a different
> path through your code via the doPOSTKvp method. Perhaps you could try
> sending XML via the Firefox "Poster" plug-in so you can examine the
> raw output in more detail.
>
> Marc.
>
> On Feb 14, 2008, at 10:26 AM, guilhem legal wrote:
>
>> the thing is that i return some xml, so it enter into the method. the
>> application whitch read my service response stop when it see the
>> response code 415,
>> but, if it look the response in a web browser it see my xml display.
>>
>> my code :
>>
>> @GET
>> public Response doGET() throws JAXBException {
>> return treatIncommingRequest(null);
>> }
>> /**
>> * Treat the incomming POST request encoded in kvp.
>> * for each parameters in the request it fill the httpContext.
>> *
>> * @return an image or xml response.
>> * @throw JAXBException
>> */
>> @POST
>> @ConsumeMime("application/x-www-form-urlencoded")
>> public Response doPOSTKvp(String request) throws JAXBException {
>> final StringTokenizer tokens = new StringTokenizer(request, "&");
>> String log = "";
>> while (tokens.hasMoreTokens()) {
>> final String token = tokens.nextToken().trim();
>> String paramName = token.substring(0, token.indexOf('='));
>> String paramValue = token.substring(token.indexOf('=')+ 1);
>> log += "put: " + paramName + "=" + paramValue + '\n';
>> context.getQueryParameters().add(paramName, paramValue);
>> }
>> logger.info("request POST kvp: " + request + '\n' + log);
>> return treatIncommingRequest(null);
>> }
>> /**
>> * Treat the incomming POST request encoded in xml.
>> *
>> * @return an image or xml response.
>> * @throw JAXBException
>> */
>> @POST
>> @ConsumeMime("text/xml")
>> public Response doPOSTXml(InputStream is) throws JAXBException {
>> logger.info("request POST xml: ");
>> Object request = null;
>> try {
>> request = unmarshaller.unmarshal(is);
>> } catch (UnmarshalException e) {
>> logger.severe(e.getMessage());
>> StringWriter sw = new StringWriter();
>> if (getCurrentVersion().isOWS()) {
>> OWSWebServiceException wse = new
>> OWSWebServiceException("The XML request is not valid",
>>
>> OWSExceptionCode.INVALID_PARAMETER_VALUE,
>>
>> null,
>>
>> getCurrentVersion().getVersionNumber());
>> marshaller.marshal(wse.getExceptionReport(), sw);
>> } else {
>> WMSWebServiceException wse = new
>> WMSWebServiceException("The XML request is not valid",
>>
>> WMSExceptionCode.INVALID_PARAMETER_VALUE,
>>
>> getCurrentVersion().getVersionNumber());
>> marshaller.marshal(wse.getServiceExceptionReport(), sw);
>> }
>> return Response.ok(sw.toString(),
>> "text/xml").build();
>> }
>> if (request != null && request instanceof AbstractRequest) {
>> AbstractRequest ar = (AbstractRequest) request;
>> context.getQueryParameters().add("VERSION", ar.getVersion());
>> }
>> return treatIncommingRequest(request);
>> }
>>
>> Guilhem Legal
>>
>>
>> Marc Hadley a écrit :
>>> 415 is returned when the format of the request isn't supported -
>>> i.e. there's no method with an @ConsumeMime for the type of request
>>> you are sending. Can you send the method signature including all the
>>> annotations and let us know what the media type of the request is.
>>>
>>> Marc.
>>>
>>> On Feb 14, 2008, at 10:01 AM, guilhem legal wrote:
>>>
>>>> hi!
>>>>
>>>> i'm testing my webservice using jersey on a server whitch verify
>>>> the validity of my xml,.. anyway,
>>>> it appears that some of my response have an header with
>>>> responseCode 415 witch is problematic.
>>>>
>>>> I return xml like that :
>>>>
>>>> StringWriter sw = new StringWriter();
>>>> marshaller.marshal(worker.getCapabilities(gc), sw);
>>>> return Response.ok(sw.toString(), "text/xml").build();
>>>>
>>>> how can i avoinding that?
>>>>
>>>> Guilhem Legal
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>
>>> ---
>>> Marc Hadley <marc.hadley at sun.com>
>>> CTO Office, Sun Microsystems.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>