You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Miguel Ángel Francisco Fernández (JIRA)" <ji...@apache.org> on 2013/04/14 21:18:16 UTC
[jira] [Comment Edited] (AXIS2-5489) Encoding GET parameters with
'+' character in generated REST clients with WSDL2Java
[ https://issues.apache.org/jira/browse/AXIS2-5489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13631379#comment-13631379 ]
Miguel Ángel Francisco Fernández edited comment on AXIS2-5489 at 4/14/13 7:17 PM:
----------------------------------------------------------------------------------
Of course, + is a legal character in a URL, but according to RFC 2396, which defines valid URI syntax, + is a reserved character in the query string, and it must be encoded: RFC 3986/ RFC1738.
As web servers treat "+" as a space, if AXIS2 client does not encode the + symbol, how can I really send a real + symbol?
If you have a look at URLEncoder ( http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html ), you will see what transformations Java does:
When encoding a String, the following rules apply:
The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
The special characters ".", "-", "*", and "_" remain the same.
The space character " " is converted into a plus sign "+".
All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte. The recommended encoding scheme to use is UTF-8. However, for compatibility reasons, if an encoding is not specified, then the default encoding of the platform is used.
was (Author: miguelafr):
Of course, + is a legal character in a URL, but according to RFC 2396, which defines valid URI syntax, + is a reserved character in the query string, and it must be encoded: RFC 3986/ RFC1738.
As web servers treat "+" as a space, if AXIS2 client does not encode the + symbol, how can I really send a real + symbol?
If you have a look at URLEncoder (http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html), you will see what transformations Java does:
When encoding a String, the following rules apply:
The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
The special characters ".", "-", "*", and "_" remain the same.
The space character " " is converted into a plus sign "+".
All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte. The recommended encoding scheme to use is UTF-8. However, for compatibility reasons, if an encoding is not specified, then the default encoding of the platform is used.
> Encoding GET parameters with '+' character in generated REST clients with WSDL2Java
> -----------------------------------------------------------------------------------
>
> Key: AXIS2-5489
> URL: https://issues.apache.org/jira/browse/AXIS2-5489
> Project: Axis2
> Issue Type: Bug
> Components: kernel, transports
> Affects Versions: 1.6.2
> Environment: Ubuntu
> Reporter: Miguel Ángel Francisco Fernández
> Priority: Blocker
> Labels: +, GET, REST, encode,
> Fix For: 1.6.2
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Using the wsdl2java tool to generate a Java client to access a REST web service described with a WSDL 2.0, the generated client does not encode the symbol '+' in GET parameters.
> For example, if I have an URL "/get_url", and I set the parameter "param" to "x+x", the symbol "+" is not encoded, and therefore it is interpreted as a space on the server ("x x"). If I try to send the parameter encoded, i.e., "%2B", then "%252B" is received in the server.
> Therefore, it is not possible to send the '+' symbol in a GET parameter.
> I guess that it is caused by the definition of the field LEGAL_CHARACTERS_IN_QUERY in the interface org.apache.axis2.description.WSDL2Constants, which is set to "-._~!$'()*+,;=:@/?"
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org