You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2011/09/01 17:51:00 UTC

Re: CXF : JAX-RS: support multiple request method designators to one method?

I could not reproduce this issue anyway, in this example, having POST 
would result in error...
I'd need to update the code to warn early anyway,
Sergey


On 30/08/11 16:03, Sergey Beryozkin wrote:
> Multiple verbs are not supported, I'm surprised both GET and POST are
> supported by CXF - it's probably a random thing, 1st time it finds GET,
> next time - POST, but it really has to be stricter.
> You can't have Query and form params combined as well
>
> Sergey
>
> On 30/08/11 11:20, jennifer wang wrote:
>> for example: Java Resource method
>>
>> @GET
>> @POST
>> @Path("/test")
>> Object get(@QueryParam("values") @FormParam("values")
>> @DefaultValue("true")
>> boolean values)
>>
>>
>> did not get any exception by calling this method from client by post
>> and by
>> get, but
>> when posting, FormParam values was not received by above method.
>>
>> A quick reply is appreciated.
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4749559.html
>>
>> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by Daniel Kulp <dk...@apache.org>.
On Monday, September 05, 2011 2:54:06 AM CXF user1109 wrote:
> About SOAP, for response/outgoing message by default CXF uses
> Provider<Source>?
> 
> If I want to do streaming for esponse/outgoing message, I need to write
> Provider<XMLStreamReader> or Provider<StaxSource>?

No, you can leave it as Provider<Source>

By default, the Source object you get in will be streaming from the request.   
It will likely be a StaxSource where you could get the XMLStreamReader.

Then return any type of Source that is convienient.   Returning a StaxSource 
should be fine if that works best for you.

Dan
 

> 
> if so how?
> 
> I am new to SOAP and thank you for your support.
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-
> designators-to-one-method-tp4749559p4769870.html Sent from the cxf-user
> mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by CXF user1109 <xw...@hotmail.com>.
About SOAP, for response/outgoing message by default CXF uses
Provider<Source>?

If I want to do streaming for esponse/outgoing message, I need to write
Provider<XMLStreamReader> or Provider<StaxSource>?

if so how?

I am new to SOAP and thank you for your support.

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4769870.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 07/09/11 11:52, Sergey Beryozkin wrote:
> Well, you probably need to get ParameterHandler registered to handle
> such expressions. If they were structured message payloads then JAXB or
> JSON readers would handle it, but in your case it appears you sent
> complex JSON expressions as form payloads (in POST case at least) - the
> default Form provider can only handle name and value pairs. Likewise, if
> such expressions are encoded as GET queries, then JAX-RS has no
> contextual info to quess it's a JSON expression, it could've been an
> encoded XML sequence too...
> So either introduce a custom MessageBodyReader handle form payloads
> containing JSON expressions - this reader would delegate to a registered
> JSON reader which your custom reader would find via an injected JAX-RS
> Providers. Same for ParameterHandler...
> Or consider avoiding a dedicated interface dealing with a non-SOAP case

I meant consider 'introducing' :-)

>
> Sergey
>
>
> On 05/09/11 09:41, CXF user1109 wrote:
>> Your question : What is a Tree ? How does a query string look like ?
>>
>> Here is the java class:
>>
>> public class Constraint {
>> private List<Term> terms;
>> private List<Constraint> innerConstraints;
>> ....
>> }
>>
>> public class Term {
>>
>> private String operator;
>> private Object[] values;
>> private Long fieldId;
>> ...
>> }
>>
>> Json string example :
>>
>> {"terms":
>> [{"values":[0.0],"operator":"lessThan","fieldId":54321}],
>> "innerConstraints":
>>
>> [{"terms":[{"values":[0.1,0.101],"operator":"between","fieldId":12345},
>>
>> {"values":[-0.0010,0.0],"operator":"between","fieldId":67890}],
>> "innerConstraints":[]}
>> ]
>> }
>>
>> Service methods are :
>>
>> @GET
>> @Path("/test")
>> List get(@QueryParam("constraint") Constraint constraint,
>> @QueryParam("value") @DefaultValue("true") boolean value)
>>
>> @POST
>> @Path("/test")
>> @WebMethod(operationName = "test")
>> List post(@FormParam("constraint") @WebParam(name = "constraint")
>> Constraint constraint,
>> @QFormParam("value") @WebParam(name = "value")
>> @DefaultValue("true") boolean value)
>>
>>
>> Thank you for your support.
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4769680.html
>>
>> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Well, you probably need to get ParameterHandler registered to handle 
such expressions. If they were structured message payloads then JAXB or 
JSON readers would handle it, but in your case it appears you sent 
complex JSON expressions as form payloads (in POST case at least) - the 
default Form provider can only handle name and value pairs. Likewise, if 
such expressions are encoded as GET queries, then JAX-RS has no 
contextual info to quess it's a JSON expression, it could've been an 
encoded XML sequence too...
So either introduce a custom MessageBodyReader handle form payloads 
containing JSON expressions - this reader would delegate to a registered 
JSON reader which your custom reader would find via an injected JAX-RS 
Providers. Same for ParameterHandler...
Or consider avoiding a dedicated interface dealing with a non-SOAP case

Sergey


On 05/09/11 09:41, CXF user1109 wrote:
> Your question :  What is a Tree ? How does a query string look like ?
>
> Here is the java class:
>
> public class Constraint {
>    private List<Term>  terms;
>    private List<Constraint>  innerConstraints;
>    ....
> }
>
> public class Term {
>
>    private String operator;
>    private Object[] values;
>    private Long fieldId;
>    ...
> }
>
> Json string example :
>
> {"terms":
>          [{"values":[0.0],"operator":"lessThan","fieldId":54321}],
> "innerConstraints":
>
> [{"terms":[{"values":[0.1,0.101],"operator":"between","fieldId":12345},
>
> {"values":[-0.0010,0.0],"operator":"between","fieldId":67890}],
>           "innerConstraints":[]}
>          ]
> }
>
> Service methods are :
>
>    @GET
>    @Path("/test")
>    List get(@QueryParam("constraint") Constraint constraint,
>               @QueryParam("value") @DefaultValue("true") boolean value)
>
>    @POST
>    @Path("/test")
>    @WebMethod(operationName = "test")
>    List post(@FormParam("constraint") @WebParam(name = "constraint")
> Constraint constraint,
>                 @QFormParam("value") @WebParam(name = "value")
> @DefaultValue("true") boolean value)
>
>
> Thank you for your support.
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4769680.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by CXF user1109 <xw...@hotmail.com>.
Your question :  What is a Tree ? How does a query string look like ? 

Here is the java class:

public class Constraint {
  private List<Term> terms;
  private List<Constraint> innerConstraints;
  ....
}

public class Term {

  private String operator;
  private Object[] values;
  private Long fieldId;
  ...
}

Json string example : 

{"terms":
        [{"values":[0.0],"operator":"lessThan","fieldId":54321}],
"innerConstraints":
       
[{"terms":[{"values":[0.1,0.101],"operator":"between","fieldId":12345},
                 
{"values":[-0.0010,0.0],"operator":"between","fieldId":67890}],
         "innerConstraints":[]}
        ]
}

Service methods are :

  @GET
  @Path("/test")
  List get(@QueryParam("constraint") Constraint constraint,
             @QueryParam("value") @DefaultValue("true") boolean value)

  @POST
  @Path("/test")
  @WebMethod(operationName = "test")
  List post(@FormParam("constraint") @WebParam(name = "constraint")
Constraint constraint,
               @QFormParam("value") @WebParam(name = "value")
@DefaultValue("true") boolean value)


Thank you for your support.

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4769680.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 02/09/11 08:03, CXF user1109 wrote:
> Something is unrelated
>
> 1. about 'Parameter beans': @QueryParam("") Tree tree,
>
> Question: if Tree has/contains a collection of Tree,
> it will work?
>
What is a Tree ? How does a query string look like ?

> Currently I have to unmarshaling xml String of the tree myself through
> Tree(String tree). It seems not right.
>
> I need these both for JAX-WS and JAX-RS.
>
> 2.  from CXF documentation, I am clear XML is streamed and can be buffered
> if case of error,
>      how about Json, with you default Json provider, do you the similar thing
> like jaxb( streaming and error
>      handling)?
>      And for SOAP, xml streaming is by default or app developer must to write
> a provider<StreamXMLapi>  to  have xml streamed?
>
Jettison does not support streaming right now - you can use Jackson if 
needed

Sergey

> Thanks
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4761324.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by CXF user1109 <xw...@hotmail.com>.
Something is unrelated 

1. about 'Parameter beans': @QueryParam("") Tree tree,

Question: if Tree has/contains a collection of Tree,
it will work?

Currently I have to unmarshaling xml String of the tree myself through
Tree(String tree). It seems not right.

I need these both for JAX-WS and JAX-RS.

2.  from CXF documentation, I am clear XML is streamed and can be buffered
if case of error, 
    how about Json, with you default Json provider, do you the similar thing
like jaxb( streaming and error
    handling)?
    And for SOAP, xml streaming is by default or app developer must to write
a provider<StreamXMLapi> to  have xml streamed?

Thanks


--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4761324.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF : JAX-RS: support multiple request method designators to one method?

Posted by CXF user1109 <xw...@hotmail.com>.
I got the case from other developers so the description maybe not precised.

I did test myself. The second designator is ignored by CXF. 
CXF gives WARNING in this case will be helpful.

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-support-multiple-request-method-designators-to-one-method-tp4749559p4761202.html
Sent from the cxf-user mailing list archive at Nabble.com.