You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabo Manuel <km...@solegysystems.com> on 2009/12/04 10:09:44 UTC

Re: JAX-RS : initial WADL support

Hi Sergey,

Sorry for the delayed response to this thread. I am currently checking 
the generated WADL using 2.2.5. A few things I did to make it work:

1. Update consumes from */* to text/xml as the prior ends up showing 
only as:

<request>
<representation mediaType="*/*"/>
</request>

2. have namespace in the XML-related annotation of each class. Have not 
tested yet relying on pagkage.info class yet.

One thing though, see sample below:

<representation mediaType="text/xml" element="prefix27:Route"/>

The object Route is defined above, but the 'prefix27' part is not 
defined anywhere else. I think the same goes for 'xs' and 'tns' 
prefixes, is this ok?

Also, since I had to change */* to something more specifc, wouldn't this 
conflict with one of the major advantages of CXF, i.e. ability to 
automatically handle json, xml, etc without any other changes?

Also, is it possible to configure somewhere to NOT apply the 
interceptors when viewing the wadl? I have my own implementation of 
http-auth digest and the password is being required whenever the wadl is 
being viewed. I was hoping it should be viewable without need of auth 
like wsdl.

Thanks again in advance.

Gabo

Sergey Beryozkin wrote:
> Hi Gabo
>
>
>> Hi Sergey,
>>
>> Thanks too! 2.2.4 then?
>
> Yeah, as far as the introspection of package-info.java is concerned. 
> If you don't have many JAXB classes then simply add a namespace to 
> @XmlRootElements....If you really need it right now then you might 
> want to register a custom WADLGenerator by copying the code from the 
> trunk, as a provider....
>
> cheers, Sergey
>
>>
>> Also, to answer your question, this is the annotation used in the 
>> package-info class:
>>
>> @javax.xml.bind.annotation.XmlSchema(namespace = "http://domain.some/",
>>                                     elementFormDefault = 
>> javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
>>
>> I just took this from the samples/user's guide.
>>
>> Gabo
>>
>> Sergey Beryozkin wrote:
>>> Hi Gabo
>>>
>>> I've just got it fixed. WADLgenerator will now introspect 
>>> package-info.java
>>> in cases when @XmlRootElement has only a local name set and if the 
>>> namespace
>>> is available then the resulting WADL will correctly link to a generated
>>> schema element....
>>>
>>> thanks for raising this issue
>>> Sergey
>>>
>>>
>>> Sergey Beryozkin wrote:
>>>
>>>> Hi Gabo
>>>>
>>>> MyObject has @XmlRootElement with only a local name specified. Does
>>>> package-info.java has a namespace specified too, in addition to the 
>>>> local
>>>> name ?
>>>>
>>>> cheers, Sergey
>>>>
>>>>
>>>> Gabo Manuel wrote:
>>>>
>>>>> Hi Sergey,
>>>>>
>>>>> I am a bit confused. How do I supply the namespace needed? I 
>>>>> thought the package-info.java would be enough.
>>>>>
>>>>> Yes, for now I would be limiting the consume to just text/xml. The 
>>>>> initial intent was to take advantage of CXF's handling between xml 
>>>>> and json. But for now, we would be sticking to text/xml.
>>>>>
>>>>> Gabo
>>>>>
>>>>> Sergey Beryozkin wrote:
>>>>>
>>>>>> Hi Gabo
>>>>>>
>>>>>> thanks... The reason you only see the '<representation/>' for my 
>>>>>> MyObject is that
>>>>>> there's no namespace available , so even though the <grammars/> 
>>>>>> section
>>>>>> has
>>>>>> the schema embedded there's no way to link to it from the
>>>>>> <representation/>.
>>>>>> May be I should have some XML comment generated which will advise to
>>>>>> check
>>>>>> the schema (with no namespace) ?
>>>>>> You might also want to update Consumes("*/*") to require a more 
>>>>>> specific
>>>>>> media type.
>>>>>>
>>>>>>
>>>>>>> I haven't tried it lately without the providers, but are 
>>>>>>> primitives now
>>>>>>> supported out of the box?
>>>>>>>
>>>>>> They are but only for text/plain. I'll add a task to wrap them in 
>>>>>> some
>>>>>> tag
>>>>>> like <response> for xml media types
>>>>>>
>>>>>>
>>>>>>> Also, is there somewhere to look to be able to use the tool that
>>>>>>> creates
>>>>>>> an http-centric client-code from the wadl?
>>>>>>>
>>>>>> No, I haven't started working on the code gen tool yet....But 
>>>>>> it's on
>>>>>> the
>>>>>> map
>>>>>>
>>>>>> cheers, Sergey
>>>>>>
>>>>>>
>>>>>>
>>>>>> Gabo Manuel wrote:
>>>>>>
>>>>>>> Hi Sergey,
>>>>>>>
>>>>>>> Sorry for the late response. I may have misrepresented the 
>>>>>>> method, it should be as follows:
>>>>>>>
>>>>>>> @WebService(name="MyObjectService")
>>>>>>> @SOAPBinding(use=Use.LITERAL, style=Style.RPC)
>>>>>>> @Consumes("*/*")
>>>>>>> @Produces("text/xml")
>>>>>>> @Path("/MyObjects")
>>>>>>> public interface MyObjectService{
>>>>>>>     @GET
>>>>>>>     @Path("/")
>>>>>>>     @WebMethod
>>>>>>>     @WebResult(name="myObjectInstance")
>>>>>>>     public MyObject getMyObject(
>>>>>>>             @QueryParam("uniqueIDField")
>>>>>>>             @WebParam(name="uniqueIDField")
>>>>>>>             long uniqueIDField)
>>>>>>>     ;
>>>>>>>
>>>>>>>     @PUT
>>>>>>>     @Path("/")
>>>>>>>     @WebMethod
>>>>>>>     @WebResult(name="uniqueIDField")
>>>>>>>     public long insertMyObject(
>>>>>>>             @WebParam(name="myObjectInstance")
>>>>>>>             MyObject myObjectInstance,
>>>>>>>             @QueryParam("reason")
>>>>>>>             @WebParam(name="reason")
>>>>>>>             String reason
>>>>>>>             )
>>>>>>>     ;
>>>>>>> }
>>>>>>>
>>>>>>> @WebService(endpointInterface="some.domain.MyObjectService", 
>>>>>>> serviceName="MyObjectService", portName="MyObjectServicePort")
>>>>>>> public class MyObjectServiceImpl implements MyObjectService{
>>>>>>>     public MyObject getMyObject(long uniqueIDField) throws 
>>>>>>> SolegyContingencyException{
>>>>>>>         return new MyObject();
>>>>>>>     }
>>>>>>>     public long insertMyObject(MyObject myObjectInstance, String
>>>>>>> reason) throws SolegyContingencyException{
>>>>>>>         return 1;
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>> @XmlType(name="MyObject")
>>>>>>> @XmlAccessorType(XmlAccessType.PROPERTY)
>>>>>>> @XmlRootElement(name="MyObject")
>>>>>>> public class MyObject {
>>>>>>>     private long uniqueIDField;
>>>>>>>     @GET
>>>>>>>     @Path("/uniqueIDField")
>>>>>>>     public long getUniqueIDField() {
>>>>>>>         return uniqueIDField;
>>>>>>>     }
>>>>>>>     public void setUniqueIDField(long uniqueIDField) {
>>>>>>>         this.uniqueIDField = uniqueIDField;
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>> The wadl section i get is something as follows:
>>>>>>>
>>>>>>> <method name="GET">
>>>>>>>   <request>
>>>>>>>     </request>
>>>>>>>   <response>
>>>>>>>     <representation mediaType="text/xml"/>
>>>>>>>   </response>
>>>>>>> </method>
>>>>>>> <method name="PUT">
>>>>>>>   <request>
>>>>>>>     <representation/>
>>>>>>>     </request>
>>>>>>>   <response>
>>>>>>>     <!-- Primitive type : xs:long --><representation
>>>>>>> mediaType="text/xml"/>
>>>>>>>   </response>
>>>>>>> </method>
>>>>>>>
>>>>>>> And yes, I did specify text/xml. I also have providers included 
>>>>>>> to wrap the response in tags. I had to add the providers because 
>>>>>>> at the time (2.0), primitives were not supported. I haven't 
>>>>>>> tried it lately without the providers, but are primitives now 
>>>>>>> supported out of the box?
>>>>>>>
>>>>>>> Also, is there somewhere to look to be able to use the tool that
>>>>>>> creates an http-centric client-code from the wadl?
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>> Gabo.
>>>>>>>
>>>>>>> Sergey Beryozkin wrote:
>>>>>>>
>>>>>>>> Hi Gabo
>>>>>>>>
>>>>>>>> It is an 'Object' so a WSDL generator has no idea what else to 
>>>>>>>> say,
>>>>>>>> apart
>>>>>>>> from <representation/>. If you add "Consumes' with some values 
>>>>>>>> then
>>>>>>>> you'll
>>>>>>>> get a bit more specific tag...
>>>>>>>>
>>>>>>>>
>>>>>>>> However, there appears to be a bug :
>>>>>>>>
>>>>>>>> <response><!-- Primitive type : xs:long --><representation
>>>>>>>> mediaType="text/xml"/></response></method></resource>
>>>>>>>>
>>>>>>>> or do you have Produces('text/xml') on the class itself ? Can you
>>>>>>>> please
>>>>>>>> send me a class sample so that I can fix it ?
>>>>>>>>
>>>>>>>> cheers, Sergey
>>>>>>>>
>>>>>>>
>>>>>>   
>>>>>> ------------------------------------------------------------------------ 
>>>>>>
>>>>>>
>>>>>>
>>>>>> No virus found in this incoming message.
>>>>>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 
>>>>>> 270.13.62/2315 - Release Date:
>>>>>> 08/20/09 06:05:00
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>   
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 
>>> 270.13.65/2323 - Release Date: 08/24/09 06:05:00
>>>
>>>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.409 / Virus Database: 270.13.66/2325 - Release Date: 08/25/09 06:08:00
>
>   

Re: JAX-RS : initial WADL support

Posted by John Klassa <jo...@klassa.com>.
Just tried it...  That rocks!

On Dec 7, 2009, at 12:04 PM, Sergey Beryozkin wrote:

> Hi, some info can be found here :
> 
> http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-ServicelistingsandWADLsupport
> 
> cheers, Sergey
> 
> 
> Hi,
> 
> How does one auto-generate a WADL from a JAX-RS implementation?  Or am I reading this incorrectly?
> 
> Thanks!
> 
> On Dec 7, 2009, at 7:57 AM, Sergey Beryozkin wrote:
> 
>> Hi Gabo
>> 
>>> Hi Sergey,
>>> Sorry about that. But you did get the idea tho. :D
>>>> Is it the wadl:request element which has no links to the schema types ? If yes then it is expected when @Consumes is set to */*, given that it may even be that only a non-XML format which is accepted by a method...
>>> Shouldn't the method still show some description of what the method is expecting? Maybe a redundancy of what was described in the grammar.
>> 
>> See http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
>> 
>>> I would be trying having multiple specific values and update this thread of the results. Might take a while, got dragged to another task.
>> 
>> Having @Consumes with multiple values will result in the generated WADL reflecting it. Same for @Produces.
>> 
>> hope it  helps, Sergey
>> 
>>> Thanks again!
>>> Gabo
>>>> 
>>>> cheers, Sergey
> 


Re: JAX-RS : initial WADL support

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi, some info can be found here :

http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-ServicelistingsandWADLsupport

cheers, Sergey


Hi,

How does one auto-generate a WADL from a JAX-RS implementation?  Or am I reading this incorrectly?

Thanks!

On Dec 7, 2009, at 7:57 AM, Sergey Beryozkin wrote:

> Hi Gabo
>
>> Hi Sergey,
>> Sorry about that. But you did get the idea tho. :D
>>> Is it the wadl:request element which has no links to the schema types ? If yes then it is expected when @Consumes is set to */*, 
>>> given that it may even be that only a non-XML format which is accepted by a method...
>> Shouldn't the method still show some description of what the method is expecting? Maybe a redundancy of what was described in the 
>> grammar.
>
> See http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
>
>> I would be trying having multiple specific values and update this thread of the results. Might take a while, got dragged to 
>> another task.
>
> Having @Consumes with multiple values will result in the generated WADL reflecting it. Same for @Produces.
>
> hope it  helps, Sergey
>
>> Thanks again!
>> Gabo
>>>
>>> cheers, Sergey


Re: JAX-RS : initial WADL support

Posted by John Klassa <jo...@klassa.com>.
Hi,

How does one auto-generate a WADL from a JAX-RS implementation?  Or am I reading this incorrectly?

Thanks!

On Dec 7, 2009, at 7:57 AM, Sergey Beryozkin wrote:

> Hi Gabo
> 
>> Hi Sergey,
>> Sorry about that. But you did get the idea tho. :D
>>> Is it the wadl:request element which has no links to the schema types ? If yes then it is expected when @Consumes is set to */*, given that it may even be that only a non-XML format which is accepted by a method...
>> Shouldn't the method still show some description of what the method is expecting? Maybe a redundancy of what was described in the grammar.
> 
> See http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
> 
>> I would be trying having multiple specific values and update this thread of the results. Might take a while, got dragged to another task.
> 
> Having @Consumes with multiple values will result in the generated WADL reflecting it. Same for @Produces.
> 
> hope it  helps, Sergey
> 
>> Thanks again!
>> Gabo
>>> 
>>> cheers, Sergey


Re: JAX-RS : initial WADL support

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

> Hi Sergey,
>
> Given he following:
>
> @WebService(name="MyService", targetNamespace="http://some.domain.com/")
> @SOAPBinding(use=Use.LITERAL, style=Style.RPC)
> @Consumes("text/xml")
> @Produces("text/xml")
> @Path("/")
> public interface MyService {
>
>    @GET
>    @Path("/search/")
>    @WebMethod
>    @WebResult(name="myObjects")
>    public List<MyObject> getMyObjects(...);
> }
>
> and
>
> @XmlType(name="MyObject", namespace="http://some.domain.com")
> @XmlAccessorType(XmlAccessType.PROPERTY)
> @XmlRootElement(name="MyObject", namespace="http://some.domain.com")
> public class MyObject
>
> The object description is accurate. However, the method is displayed as follows:
>
> <resource path="/search/">
> <method name="GET">
> <request>
> ...
> </request>
> <response>
> <representation mediaType="text/xml"/>
> </response>
> </method>
> </resource>
>
> Are lists not supported for WADL?

I kind of referred to it a couple of times already. Basically, even though JAX-RS implementations do let people write resource 
methods accepting/returning explicit collections, it is really a convinience hack which is something I've relied upon too in my own 
JAX-RS services coding.

The question, what is the schema type for say Collection<Bar> ? Or Set<Foo>  or List<Baz> ? CXF JAXRS JAXBElementProvider lets users 
customize the name of the enclosing collection root, so it is really tricky to have a schema generated for say List<MyObject>.
If users would like to have their collections of JAXB types be described in WADLs then I'd recommend wrapping them, ex, in, say, 
MyObjects JAXB class...

I might consider configuring the WADLGenerator such that it uses the registered JAXBProvider to get the actual JAXBContext 
representing a given explicit collection and using it to have the schema generated...

hope it helps, Sergey

>
> Thanks in advance.
>
> Gabo
>
>
> Sergey Beryozkin wrote:
>> Hi Gabo
>>
>>> Hi Sergey,
>>>
>>> Sorry about that. But you did get the idea tho. :D
>>>
>>>> Is it the wadl:request element which has no links to the schema types ? If yes then it is expected when @Consumes is set to 
>>>> */*, given that it may even be that only a non-XML format which is accepted by a method...
>>> Shouldn't the method still show some description of what the method is expecting? Maybe a redundancy of what was described in 
>>> the grammar.
>>
>> See http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
>>
>>>
>>> I would be trying having multiple specific values and update this thread of the results. Might take a while, got dragged to 
>>> another task.
>>
>> Having @Consumes with multiple values will result in the generated WADL reflecting it. Same for @Produces.
>>
>> hope it  helps, Sergey
>>
>>>
>>> Thanks again!
>>>
>>> Gabo
>>>
>>>>
>>>> cheers, Sergey
>> 


Re: JAX-RS : initial WADL support

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Given he following:

@WebService(name="MyService", targetNamespace="http://some.domain.com/")
@SOAPBinding(use=Use.LITERAL, style=Style.RPC)
@Consumes("text/xml")
@Produces("text/xml")
@Path("/")
public interface MyService {

    @GET
    @Path("/search/")
    @WebMethod
    @WebResult(name="myObjects")
    public List<MyObject> getMyObjects(...);
}

and

@XmlType(name="MyObject", namespace="http://some.domain.com")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name="MyObject", namespace="http://some.domain.com")
public class MyObject

The object description is accurate. However, the method is displayed as 
follows:

<resource path="/search/">
<method name="GET">
<request>
...
</request>
<response>
<representation mediaType="text/xml"/>
</response>
</method>
</resource>

Are lists not supported for WADL?

Thanks in advance.

Gabo


Sergey Beryozkin wrote:
> Hi Gabo
>
>> Hi Sergey,
>>
>> Sorry about that. But you did get the idea tho. :D
>>
>>> Is it the wadl:request element which has no links to the schema 
>>> types ? If yes then it is expected when @Consumes is set to */*, 
>>> given that it may even be that only a non-XML format which is 
>>> accepted by a method...
>> Shouldn't the method still show some description of what the method 
>> is expecting? Maybe a redundancy of what was described in the grammar.
>
> See 
> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java 
>
>
>>
>> I would be trying having multiple specific values and update this 
>> thread of the results. Might take a while, got dragged to another task.
>
> Having @Consumes with multiple values will result in the generated 
> WADL reflecting it. Same for @Produces.
>
> hope it  helps, Sergey
>
>>
>> Thanks again!
>>
>> Gabo
>>
>>>
>>> cheers, Sergey
>

Re: JAX-RS : initial WADL support

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

> Hi Sergey,
> 
> Sorry about that. But you did get the idea tho. :D
> 
>> Is it the wadl:request element which has no links to the schema types 
>> ? If yes then it is expected when @Consumes is set to */*, given that 
>> it may even be that only a non-XML format which is accepted by a 
>> method...
> Shouldn't the method still show some description of what the method is 
> expecting? Maybe a redundancy of what was described in the grammar.

See http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java

> 
> I would be trying having multiple specific values and update this thread 
> of the results. Might take a while, got dragged to another task.

Having @Consumes with multiple values will result in the generated WADL reflecting it. Same for @Produces.

hope it  helps, Sergey

> 
> Thanks again!
> 
> Gabo
> 
>>
>> cheers, Sergey

Re: JAX-RS : initial WADL support

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Sorry about that. But you did get the idea tho. :D

> Is it the wadl:request element which has no links to the schema types 
> ? If yes then it is expected when @Consumes is set to */*, given that 
> it may even be that only a non-XML format which is accepted by a 
> method...
Shouldn't the method still show some description of what the method is 
expecting? Maybe a redundancy of what was described in the grammar.

I would be trying having multiple specific values and update this thread 
of the results. Might take a while, got dragged to another task.

Thanks again!

Gabo

>
> cheers, Sergey

Re: JAX-RS : initial WADL support

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Gabo

> Hi Sergey,
>
>
> Re: */*
>
> If I set the annotation @Consumes to */* and the @Produces to ("text/xml"), the wadl is not generated properly. I guess it is 
> because of the difference between the two? In this case, is it really still advisable to have a separate annotation? I mean, 
> shouldn't the annotation be reduced to 1 if it is required to have them as same values?

I'm sorry but it's been awhile since we discussed the actual issue you're seeing with the generated WADL...
Can you remind me please what exactly is happening ? Can you please post a sample resource class and method
(with @Consumes set to */* and the @Produces set to ("text/xml")) and clarify what is missing from the generated WADL ?

Is it the wadl:request element which has no links to the schema types ? If yes then it is expected when @Consumes is set to */*, 
given that it may even be that only a non-XML format which is accepted by a method...

cheers, Sergey



>
> Gabo
>
> Sergey Beryozkin wrote:
>> Hi
>>
>>> Hi Sergey,
>>>
>>> Sorry for the delayed response to this thread. I am currently checking the generated WADL using 2.2.5. A few things I did to 
>>> make it work:
>>>
>>> 1. Update consumes from */* to text/xml as the prior ends up showing only as:
>>>
>>> <request>
>>> <representation mediaType="*/*"/>
>>> </request>
>>>
>>> 2. have namespace in the XML-related annotation of each class. Have not tested yet relying on pagkage.info class yet.
>>>
>>> One thing though, see sample below:
>>>
>>> <representation mediaType="text/xml" element="prefix27:Route"/>
>>>
>>> The object Route is defined above, but the 'prefix27' part is not defined anywhere else. I think the same goes for 'xs' and 
>>> 'tns' prefixes, is this ok?
>>
>> the corresponding namespaces must be declared at the wadl:application level, can you verify please ? Likewise "prefix27" must 
>> poin to a namespace for one of the schemas in the grammars section. If you're looking at the generated wadl from the Firefox then 
>> you need to tell it to show the actual page source...
>>
>>>
>>> Also, since I had to change */* to something more specifc, wouldn't this conflict with one of the major advantages of CXF, i.e. 
>>> ability to automatically handle json, xml, etc without any other changes?
>>
>> Sorry, not sure what you mean. If your class has say application/xml & application/json produces values then the generated WADL 
>> should have it reflected
>>
>>>
>>> Also, is it possible to configure somewhere to NOT apply the interceptors when viewing the wadl? I have my own implementation of 
>>> http-auth digest and the password is being required whenever the wadl is being viewed. I was hoping it should be viewable 
>>> without need of auth like wsdl.
>>
>> Can you interceptor check that it is a _wadl query and if yes then let the processing continue ?
>>
>> cheers, Sergey 


Re: JAX-RS : initial WADL support

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Sergey,

Re: prefix definition

I tried to view page source, and the prefix definition is there. I think 
this behavior is just with firefox, did not need to do this with IE.

Re: interceptor check for _wadl

Yep, did the same after I sent the email before.

Re: */*

If I set the annotation @Consumes to */* and the @Produces to 
("text/xml"), the wadl is not generated properly. I guess it is because 
of the difference between the two? In this case, is it really still 
advisable to have a separate annotation? I mean, shouldn't the 
annotation be reduced to 1 if it is required to have them as same values?

Gabo

Sergey Beryozkin wrote:
> Hi
>
>> Hi Sergey,
>>
>> Sorry for the delayed response to this thread. I am currently 
>> checking the generated WADL using 2.2.5. A few things I did to make 
>> it work:
>>
>> 1. Update consumes from */* to text/xml as the prior ends up showing 
>> only as:
>>
>> <request>
>> <representation mediaType="*/*"/>
>> </request>
>>
>> 2. have namespace in the XML-related annotation of each class. Have 
>> not tested yet relying on pagkage.info class yet.
>>
>> One thing though, see sample below:
>>
>> <representation mediaType="text/xml" element="prefix27:Route"/>
>>
>> The object Route is defined above, but the 'prefix27' part is not 
>> defined anywhere else. I think the same goes for 'xs' and 'tns' 
>> prefixes, is this ok?
>
> the corresponding namespaces must be declared at the wadl:application 
> level, can you verify please ? Likewise "prefix27" must poin to a 
> namespace for one of the schemas in the grammars section. If you're 
> looking at the generated wadl from the Firefox then you need to tell 
> it to show the actual page source...
>
>>
>> Also, since I had to change */* to something more specifc, wouldn't 
>> this conflict with one of the major advantages of CXF, i.e. ability 
>> to automatically handle json, xml, etc without any other changes?
>
> Sorry, not sure what you mean. If your class has say application/xml & 
> application/json produces values then the generated WADL should have 
> it reflected
>
>>
>> Also, is it possible to configure somewhere to NOT apply the 
>> interceptors when viewing the wadl? I have my own implementation of 
>> http-auth digest and the password is being required whenever the wadl 
>> is being viewed. I was hoping it should be viewable without need of 
>> auth like wsdl.
>
> Can you interceptor check that it is a _wadl query and if yes then let 
> the processing continue ?
>
> cheers, Sergey

Re: JAX-RS : initial WADL support

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

> Hi Sergey,
>
> Sorry for the delayed response to this thread. I am currently checking the generated WADL using 2.2.5. A few things I did to make 
> it work:
>
> 1. Update consumes from */* to text/xml as the prior ends up showing only as:
>
> <request>
> <representation mediaType="*/*"/>
> </request>
>
> 2. have namespace in the XML-related annotation of each class. Have not tested yet relying on pagkage.info class yet.
>
> One thing though, see sample below:
>
> <representation mediaType="text/xml" element="prefix27:Route"/>
>
> The object Route is defined above, but the 'prefix27' part is not defined anywhere else. I think the same goes for 'xs' and 'tns' 
> prefixes, is this ok?

the corresponding namespaces must be declared at the wadl:application level, can you verify please ? Likewise "prefix27" must poin 
to a namespace for one of the schemas in the grammars section. If you're looking at the generated wadl from the Firefox then you 
need to tell it to show the actual page source...

>
> Also, since I had to change */* to something more specifc, wouldn't this conflict with one of the major advantages of CXF, i.e. 
> ability to automatically handle json, xml, etc without any other changes?

Sorry, not sure what you mean. If your class has say application/xml & application/json produces values then the generated WADL 
should have it reflected

>
> Also, is it possible to configure somewhere to NOT apply the interceptors when viewing the wadl? I have my own implementation of 
> http-auth digest and the password is being required whenever the wadl is being viewed. I was hoping it should be viewable without 
> need of auth like wsdl.

Can you interceptor check that it is a _wadl query and if yes then let the processing continue ?

cheers, Sergey

>
> Thanks again in advance.
>
> Gabo
>
> Sergey Beryozkin wrote:
>> Hi Gabo
>>
>>
>>> Hi Sergey,
>>>
>>> Thanks too! 2.2.4 then?
>>
>> Yeah, as far as the introspection of package-info.java is concerned. If you don't have many JAXB classes then simply add a 
>> namespace to @XmlRootElements....If you really need it right now then you might want to register a custom WADLGenerator by 
>> copying the code from the trunk, as a provider....
>>
>> cheers, Sergey
>>
>>>
>>> Also, to answer your question, this is the annotation used in the package-info class:
>>>
>>> @javax.xml.bind.annotation.XmlSchema(namespace = "http://domain.some/",
>>>                                     elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
>>>
>>> I just took this from the samples/user's guide.
>>>
>>> Gabo
>>>
>>> Sergey Beryozkin wrote:
>>>> Hi Gabo
>>>>
>>>> I've just got it fixed. WADLgenerator will now introspect package-info.java
>>>> in cases when @XmlRootElement has only a local name set and if the namespace
>>>> is available then the resulting WADL will correctly link to a generated
>>>> schema element....
>>>>
>>>> thanks for raising this issue
>>>> Sergey
>>>>
>>>>
>>>> Sergey Beryozkin wrote:
>>>>
>>>>> Hi Gabo
>>>>>
>>>>> MyObject has @XmlRootElement with only a local name specified. Does
>>>>> package-info.java has a namespace specified too, in addition to the local
>>>>> name ?
>>>>>
>>>>> cheers, Sergey
>>>>>
>>>>>
>>>>> Gabo Manuel wrote:
>>>>>
>>>>>> Hi Sergey,
>>>>>>
>>>>>> I am a bit confused. How do I supply the namespace needed? I thought the package-info.java would be enough.
>>>>>>
>>>>>> Yes, for now I would be limiting the consume to just text/xml. The initial intent was to take advantage of CXF's handling 
>>>>>> between xml and json. But for now, we would be sticking to text/xml.
>>>>>>
>>>>>> Gabo
>>>>>>
>>>>>> Sergey Beryozkin wrote:
>>>>>>
>>>>>>> Hi Gabo
>>>>>>>
>>>>>>> thanks... The reason you only see the '<representation/>' for my MyObject is that
>>>>>>> there's no namespace available , so even though the <grammars/> section
>>>>>>> has
>>>>>>> the schema embedded there's no way to link to it from the
>>>>>>> <representation/>.
>>>>>>> May be I should have some XML comment generated which will advise to
>>>>>>> check
>>>>>>> the schema (with no namespace) ?
>>>>>>> You might also want to update Consumes("*/*") to require a more specific
>>>>>>> media type.
>>>>>>>
>>>>>>>
>>>>>>>> I haven't tried it lately without the providers, but are primitives now
>>>>>>>> supported out of the box?
>>>>>>>>
>>>>>>> They are but only for text/plain. I'll add a task to wrap them in some
>>>>>>> tag
>>>>>>> like <response> for xml media types
>>>>>>>
>>>>>>>
>>>>>>>> Also, is there somewhere to look to be able to use the tool that
>>>>>>>> creates
>>>>>>>> an http-centric client-code from the wadl?
>>>>>>>>
>>>>>>> No, I haven't started working on the code gen tool yet....But it's on
>>>>>>> the
>>>>>>> map
>>>>>>>
>>>>>>> cheers, Sergey
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Gabo Manuel wrote:
>>>>>>>
>>>>>>>> Hi Sergey,
>>>>>>>>
>>>>>>>> Sorry for the late response. I may have misrepresented the method, it should be as follows:
>>>>>>>>
>>>>>>>> @WebService(name="MyObjectService")
>>>>>>>> @SOAPBinding(use=Use.LITERAL, style=Style.RPC)
>>>>>>>> @Consumes("*/*")
>>>>>>>> @Produces("text/xml")
>>>>>>>> @Path("/MyObjects")
>>>>>>>> public interface MyObjectService{
>>>>>>>>     @GET
>>>>>>>>     @Path("/")
>>>>>>>>     @WebMethod
>>>>>>>>     @WebResult(name="myObjectInstance")
>>>>>>>>     public MyObject getMyObject(
>>>>>>>>             @QueryParam("uniqueIDField")
>>>>>>>>             @WebParam(name="uniqueIDField")
>>>>>>>>             long uniqueIDField)
>>>>>>>>     ;
>>>>>>>>
>>>>>>>>     @PUT
>>>>>>>>     @Path("/")
>>>>>>>>     @WebMethod
>>>>>>>>     @WebResult(name="uniqueIDField")
>>>>>>>>     public long insertMyObject(
>>>>>>>>             @WebParam(name="myObjectInstance")
>>>>>>>>             MyObject myObjectInstance,
>>>>>>>>             @QueryParam("reason")
>>>>>>>>             @WebParam(name="reason")
>>>>>>>>             String reason
>>>>>>>>             )
>>>>>>>>     ;
>>>>>>>> }
>>>>>>>>
>>>>>>>> @WebService(endpointInterface="some.domain.MyObjectService", serviceName="MyObjectService", portName="MyObjectServicePort")
>>>>>>>> public class MyObjectServiceImpl implements MyObjectService{
>>>>>>>>     public MyObject getMyObject(long uniqueIDField) throws SolegyContingencyException{
>>>>>>>>         return new MyObject();
>>>>>>>>     }
>>>>>>>>     public long insertMyObject(MyObject myObjectInstance, String
>>>>>>>> reason) throws SolegyContingencyException{
>>>>>>>>         return 1;
>>>>>>>>     }
>>>>>>>> }
>>>>>>>>
>>>>>>>> @XmlType(name="MyObject")
>>>>>>>> @XmlAccessorType(XmlAccessType.PROPERTY)
>>>>>>>> @XmlRootElement(name="MyObject")
>>>>>>>> public class MyObject {
>>>>>>>>     private long uniqueIDField;
>>>>>>>>     @GET
>>>>>>>>     @Path("/uniqueIDField")
>>>>>>>>     public long getUniqueIDField() {
>>>>>>>>         return uniqueIDField;
>>>>>>>>     }
>>>>>>>>     public void setUniqueIDField(long uniqueIDField) {
>>>>>>>>         this.uniqueIDField = uniqueIDField;
>>>>>>>>     }
>>>>>>>> }
>>>>>>>>
>>>>>>>> The wadl section i get is something as follows:
>>>>>>>>
>>>>>>>> <method name="GET">
>>>>>>>>   <request>
>>>>>>>>     </request>
>>>>>>>>   <response>
>>>>>>>>     <representation mediaType="text/xml"/>
>>>>>>>>   </response>
>>>>>>>> </method>
>>>>>>>> <method name="PUT">
>>>>>>>>   <request>
>>>>>>>>     <representation/>
>>>>>>>>     </request>
>>>>>>>>   <response>
>>>>>>>>     <!-- Primitive type : xs:long --><representation
>>>>>>>> mediaType="text/xml"/>
>>>>>>>>   </response>
>>>>>>>> </method>
>>>>>>>>
>>>>>>>> And yes, I did specify text/xml. I also have providers included to wrap the response in tags. I had to add the providers 
>>>>>>>> because at the time (2.0), primitives were not supported. I haven't tried it lately without the providers, but are 
>>>>>>>> primitives now supported out of the box?
>>>>>>>>
>>>>>>>> Also, is there somewhere to look to be able to use the tool that
>>>>>>>> creates an http-centric client-code from the wadl?
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> Gabo.
>>>>>>>>
>>>>>>>> Sergey Beryozkin wrote:
>>>>>>>>
>>>>>>>>> Hi Gabo
>>>>>>>>>
>>>>>>>>> It is an 'Object' so a WSDL generator has no idea what else to say,
>>>>>>>>> apart
>>>>>>>>> from <representation/>. If you add "Consumes' with some values then
>>>>>>>>> you'll
>>>>>>>>> get a bit more specific tag...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> However, there appears to be a bug :
>>>>>>>>>
>>>>>>>>> <response><!-- Primitive type : xs:long --><representation
>>>>>>>>> mediaType="text/xml"/></response></method></resource>
>>>>>>>>>
>>>>>>>>> or do you have Produces('text/xml') on the class itself ? Can you
>>>>>>>>> please
>>>>>>>>> send me a class sample so that I can fix it ?
>>>>>>>>>
>>>>>>>>> cheers, Sergey
>>>>>>>>>
>>>>>>>>
>>>>>>>   ------------------------------------------------------------------------ 
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> No virus found in this incoming message.
>>>>>>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.62/2315 - Release Date:
>>>>>>> 08/20/09 06:05:00
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>   ------------------------------------------------------------------------ 
>>>>
>>>>
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.65/2323 - Release Date: 08/24/09 06:05:00
>>>>
>>>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.66/2325 - Release Date: 08/25/09 06:08:00
>>
>>