This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 159073 - Unable to Test RESTful Web Services with PUT method and Query encoded params
Summary: Unable to Test RESTful Web Services with PUT method and Query encoded params
Status: RESOLVED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Denis Anisimov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 16:12 UTC by dtrounine
Modified: 2010-09-25 02:54 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dtrounine 2009-02-24 16:12:16 UTC
JAX_RS Web Service contains the following method:

@PUT
@Produces("application/xml")
public Users updateUser(
            @QueryParam("skey")     String skey) {...}

This corresponds to the following WADL:

<method name="PUT" id="updateUser">
  <request>
    <param type="xs:string" style="query" name="skey"/>
  </request>
  <response>
    <representation mediaType="application/xml"/>
  </response>
</method>

So, the parameter skey should be encoded in URL.
However, if "Test RESTful Web Service" feature is used on that project, and an attempt is made to send PUT request with
skey parameter, the test doesn't encode the skey parameter in URL. (PUT method is selected from "Choose method to test"
list, skey value is entered in a text filed and "Test" button is pressed). Used browser: Forefox 3.0.6.

Below is the log from HTTP monitor of that test:

-----------------------------------------------------------------------
Request: PUT http://localhost:8080/myapp/user?
timestamp=1235491569844

Status: 200 (OK)

Time-Stamp: Tue, 24 Feb 2009 16:06:09 GMT

Sent:
Insert content here.

Received:

<?xml version="1.0" encoding="UTF-8"?>
   <users xmlns="http://xml.netbeans.org/schema/myapp">
       <fail>Invalid session key : null</fail>
   </users>


-----------------------------------------------------------------------

So, one can see from this log that the query string doesn't contain encoded skey parameter.
Similar problem with POST method. Testing GET method works fine, all parameters are encoded.
Comment 1 Denis Anisimov 2010-09-22 14:14:14 UTC
First of all I can't reproduce fail in response as shown in the description.
The problem exists nevertheless . 
But it is not in value encoding. 
Each parameter value is encoded via "escape()" method in javascript when
HTTP request is generated.

For POST and PUT methods there is "Content" textarea which is intended for
content of HTTP request. It always has some value ( me be empty string ""
but it is still not null  value). In this case other parameters ( in the 
described example "skey" parameter ) are ignored . Only "Content" value is 
used for HTTP request.

To fix this behavior one need to add dedicated parameters with values to the
resulting content of POST/PUT request.
Comment 2 Denis Anisimov 2010-09-23 07:37:28 UTC
changeset:   177967:2981c69b8750
user:        Denis Anisimov <ads@netbeans.org>
date:        Thu Sep 23 11:26:31 2010 +0400
summary:     Fix for BZ#159073 -  Unable to Test RESTful Web Services with PUT method and Query encoded params
Comment 3 Quality Engineering 2010-09-25 02:54:53 UTC
Integrated into 'main-golden', will be available in build *201009250000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2981c69b8750
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#159073 -  Unable to Test RESTful Web Services with PUT method and Query encoded params