You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2010/07/22 22:48:16 UTC

Re: A WADL Representation bug?

As I replied in the other email, form parameters have to be described as
query parameters as per the WADL spec.
Realistically, a representation in WADL is an XML instance so that it could
be linked to a schema element. A sequence of name/value pairs can't be

cheers, Sergey

On Thu, Jul 22, 2010 at 5:14 AM, chengy <ch...@yahoo.com.cn> wrote:

>
> cxf2.2.5 or cxf 2.2.9:
>
> WadlGenerator.java line 225:
>
>  if (isFormRequest(ori)) {
>                handleRepresentation(sb, jaxbTypes, jaxbProxy, clsMap, ori,
> null, false);
>            } else {
>                for (Parameter p : ori.getParameters()) {
>                    handleParameter(sb, jaxbTypes, jaxbProxy, clsMap, ori,
> p);
>                }
>            }
>
> the last parameter of handleRepresentation is false, why not true ?
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/A-WADL-Representation-bug-tp1805447p1805447.html
> Sent from the cxf-issues mailing list archive at Nabble.com.
>

Re: A WADL Representation bug?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Tue, Jul 27, 2010 at 1:12 PM, chengy <ch...@yahoo.com.cn> wrote:

>
> Hello, dear Sergey,
>
> what do you think of my code?
>

If someone wakes me up during the night and asks about this code - then I
will write down the signature without even looking at this email, as I've
seen this fragment quite a few times :-)


>
> --------------------------------------------------------------------------------------
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> @Produces(MediaType.TEXT_HTML)
> @Path("/createInstances")
> public int createInstances(@FormParam("workflowDefUUID") String
> workflowDefUUID, @FormParam("createUserId") String createUserId,
> @FormParam("participantId") String participantId, @FormParam("title")
> String
> title,@FormParam("boDatas") String boDatas) {return 0;};
>
> --------------------------------------------------------------------------------------
>
> if don't asign a @Produces,cxf will set MediaType.APPLICATION_OCTET_STREAM
> as a int type's mime type.
>

WADLGenerator has no idea what ContentType will be used by clients and given
that no @Produces is specified, it defaults to
MediaType.APPLICATION_OCTET_STREAM; You probably want text/plain be
explicitly specified; and just in case, CXF won't be able to convert this
int into JAXB/JSON itself.

Also please ask on the users list instead...

Sergey


> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Re-A-WADL-Representation-bug-tp1842811p2255734.html
> Sent from the cxf-dev mailing list archive at Nabble.com.
>

Re: A WADL Representation bug?

Posted by chengy <ch...@yahoo.com.cn>.
Hello, dear Sergey,

what do you think of my code?
--------------------------------------------------------------------------------------
@POST 
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) 
@Produces(MediaType.TEXT_HTML) 
@Path("/createInstances") 
public int createInstances(@FormParam("workflowDefUUID") String
workflowDefUUID, @FormParam("createUserId") String createUserId,
@FormParam("participantId") String participantId, @FormParam("title") String
title,@FormParam("boDatas") String boDatas) {return 0;}; 
--------------------------------------------------------------------------------------

if don't asign a @Produces,cxf will set MediaType.APPLICATION_OCTET_STREAM
as a int type's mime type.
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Re-A-WADL-Representation-bug-tp1842811p2255734.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Re: A WADL Representation bug?

Posted by Sergey Beryozkin <sb...@gmail.com>.
@Produces.So,I cann't use cxf generate wadl like below:
>
> <resource path="/createInstances">
>        <method name="POST">
>                <request>
>                 <representation
> mediaType="application/x-www-form-urlencoded">
>
>                 </representation>
>

here is what generated by the WADLGenerator test :

<resource path="/form2">

<method name="POST">
<request>
<representation mediaType="application/x-www-form-urlencoded">
<param name="field1" style="query" type="xs:string"/>
<param name="field2" style="query" type="xs:string"/>
</representation>
</request>
<response status="204"/>
</method>
</resource>

the corresponding test method :

@Path("/form2")
    @POST
    void form2(@FormParam("field1") String f1, @FormParam("field2") String
f2);

cheers, Sergey

Re: A WADL Representation bug?

Posted by chengy <ch...@yahoo.com.cn>.
some handleOperation code:
------------------------------------------------------------------------------------------
     if (ori.getMethodToInvoke().getParameterTypes().length != 0) {
            sb.append("<request>");
            if (isFormRequest(ori)) {
                handleRepresentation(sb, jaxbTypes, qnameResolver, clsMap,
ori, null, false);
            } else {
                for (Parameter p : ori.getParameters()) {        
                    handleParameter(sb, jaxbTypes, qnameResolver, clsMap,
ori, p);             
                }
            }
            sb.append("</request>");
        }
--------------------------------------------------------------------------------------------

handleRepresentation method:
--------------------------------------------------------------------------------------------
    private void handleRepresentation(StringBuilder sb, Set<Class<?>>
jaxbTypes, 
                                      ElementQNameResolver qnameResolver,
                                      Map<Class<?>, QName> clsMap,
OperationResourceInfo ori, 
                                      Class<?> type, boolean inbound) {
        List<MediaType> types = inbound ? ori.getConsumeTypes() :
ori.getProduceTypes();
--------------------------------------------------------------------------------------------

if "false",indicate that it's not "inbound". the form request will use
OperationResourceInfo's ProduceType,that is to say,it will use
@Produces.So,I cann't use cxf generate wadl like below:

<resource path="/createInstances">
	<method name="POST">
		<request>
		 <representation mediaType="application/x-www-form-urlencoded">
		   
		   
		   
		   
		   
		 </representation>
		</request>
		<response>
		 <!--  Primitive type : xs:int --> 
		 <representation mediaType="text/html" /> 
		</response>
	</method>
</resource>

my java code:
----------------------------------------------------------------------------------------------
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
@Path("/createInstances")
public int createInstances(@FormParam("workflowDefUUID") String
workflowDefUUID, @FormParam("createUserId") String createUserId,
@FormParam("participantId") String participantId, @FormParam("title") String
title,@FormParam("boDatas") String boDatas) throws WSDKException;
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Re-A-WADL-Representation-bug-tp1842811p2206703.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Re: A WADL Representation bug?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Ok, I've seen this question few times now, please, don't resend it again :-)
Let me ask you the question.

Given that we agree that form  parameters has to be represented as queries,
why do you keep asking
about the boolean parameter of handleRepresentation() ? Why do you think it
should be *true* ?

Sergey

On Sat, Jul 24, 2010 at 2:09 AM, chengy <ch...@yahoo.com.cn> wrote:

>
> " handleRepresentation(sb, jaxbTypes, jaxbProxy, clsMap, ori, null,
> false);"
> should be
> "handleRepresentation(sb, jaxbTypes, jaxbProxy, clsMap, ori, null, true);"
> ?
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Re-A-WADL-Representation-bug-tp1842811p1896987.html
> Sent from the cxf-dev mailing list archive at Nabble.com.
>

Re: A WADL Representation bug?

Posted by chengy <ch...@yahoo.com.cn>.
" handleRepresentation(sb, jaxbTypes, jaxbProxy, clsMap, ori, null, false);" 
should be 
"handleRepresentation(sb, jaxbTypes, jaxbProxy, clsMap, ori, null, true);" ?
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Re-A-WADL-Representation-bug-tp1842811p1896987.html
Sent from the cxf-dev mailing list archive at Nabble.com.