Hi,
Sorry for the delay in getting back to you email filter issues, I hadn't
actually heard of the wadl2Java tool before and from what you are saying
it would seem reasonable that if the method always has a non-200 status
code the the code generator should indeed generate some suitable
boilerplate code, and make it return 405.
For more complicated cases I guess the question comes down to what form
of code it should generate ether using the response object:
ReponseBuilder rb = .....
if ( case1 ) {
rb = rb.ok();
} else {
.....
}
or using exceptions, this is hard to say what is the correct version. It
probably comes down to you picking a format that feels right
and raising a bug on the tool you are using. It wouldn't be a very
difficult change to implement. The wadl2Java tool on this mailing list
only generates clients and doesn't yet produces services from a WADL.
Gerard
On 13/01/2012 05:47, Paul Duffy wrote:
> On 1/12/2012 2:52 AM, Gerard Davison wrote:
>> Paul,
>>
>> Can I ask what generator your are using?
>
> wadl2java Apache CXF 2.5.1
>
> There are others? Preferred generator?
>
>>
>> Generally you could fix the code to just return a Reponse rather than
>> void, this would give you the control you like, or you can throw
>> WebApplicationException with the status code if your prefer that way
>> of working.
>
> I assume you mean manually modify the code. I of course could
> manually code the HTTP method handlers, but such a situation also
> greatly reduces my need to use WADL.
>
> What, if any, impact do variations in <response/> elements have on
> code generation?
>
> In the wadl example I offered below, why would wadl2java not auto gen
> the code to always return the 405 error?
>
> Cheers
>
>
>>
>> Gerard
>>
>>
>>
>>
>> On 11 Jan 2012, at 23:17, Paul Duffy wrote:
>>
>>> Folks,
>>>
>>> I'm doing an evaluation before recommending wider adoption of wadl.
>>> Appreciate your patience and efforts.
>>>
>>> First question. I seem unable to impact generated code with the
>>> status attribute on the<response/> element.
>>>
>>> Sample WADL ...
>>>
>>> <resource path="test">
>>> <method name="DELETE">
>>> <response status = "405"/>
>>> </method>
>>> </resource
>>>
>>> I seem unable to generate any but the following code...
>>>
>>> /**
>>> * Created by Apache CXF WadlToJava code generator
>>> **/
>>> package application;
>>>
>>> import javax.ws.rs.DELETE;
>>> import javax.ws.rs.Path;
>>>
>>> @Path("test")
>>> public class Test {
>>> @DELETE
>>> public void DELETETest() {
>>> //TODO: implement
>>> }
>>> }
>>>
>>> How does one force code generation for specific return status from
>>> the wadl?
>>>
>>> Cheers
>>>
>>>
>>>
>>
>
--
Gerard Davison | Senior Principal Software Engineer | +44 118 924 5095
Oracle JDeveloper Web Service, Spring, Weblogic SCA Tooling Development
Oracle Corporation UK Ltd is a company incorporated in England& Wales.
Company Reg. No. 1782505.
Reg. office: Oracle Parkway, Thames Valley Park, Reading RG6 1RA.
Blog http://kingsfleet.blogspot.com Twitter kingsfleet