You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by MayBee <ma...@gmx.de> on 2015/01/23 15:05:30 UTC

included xsd's are not resolved for wadl generation

Hi again,

I have found the following in this documentation:
https://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-RepresentingexternalschemasandnonJAXBtypes

> TODO : add ignoreImports flag so that users can list root and imported
> schemas in "schemaLocations" and have them all inlined.

What is the current state here? Under progress? Any target version?
At a first glance, I could not find an "ignoreImports" property for the
JAXBElementProvider so provide my included schemas by hand by the
"schemaLocations" list.

Regards,
Malte



--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Ok. Thanks at all!
I appreciate the very good support here.



--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753677.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 28/01/15 07:38, MayBee wrote:
> Sergey Beryozkin wrote
>> I can add a property to WADLGenerator to avoid updating the relative
>> import/include references. Can you give some example of where your
>> schemas are located, how is a root schema includes/imports one of them,
>> and which URI you use (where is war context, servlet path in that URI)
>> to get a given WADL ? I'd like to see if adding such property would
>> actually work or not
>
> * Our schemas are located in seperated system interface projects. Thus they
> are finally located in the *.war within the system interface *.jar in the
> WEB-INF/lib folder.
> * The schemas are referenced via relatives paths like <include
> schemaLocation="folder/part.xsd" id="someSubXsd"/>
> * For the JaxbProvider and WadlGenerator, we address the xsds by
> "classpath:/xsd/ourSchema.xsd".
> * The URI to access the overview of differnet wadls is
> HOST:PORT/WEP_APP_ROOT_KEY/SERVLET?_wadl
> * The URI to access a specific jaxrs:server wadl is
> HOST:PORT/WEP_APP_ROOT_KEY/SERVLET/JAXRS:SERVER@base?_wadl

So if WADL does not replace a "folder/part.xsd" with an absolute URI, 
then, after issuing

/appPath/servletPath/somebase?_wadl

the default servlet would be expected to read

/appPath/servletPath/somebase/folder/part.xsd
or
/appPath/servletPath/folder/part.xsd

depending on whether the client uses URI resolve or not. Either way it 
would not find it because "folder/part.xsd" is relative to /WEB-INF/lib

I'll probably just add the option not expand relative URIs anyway in 
case such schemas can be located in a public folder...
Sergey


>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753650.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Sergey Beryozkin wrote
> I can add a property to WADLGenerator to avoid updating the relative 
> import/include references. Can you give some example of where your 
> schemas are located, how is a root schema includes/imports one of them, 
> and which URI you use (where is war context, servlet path in that URI) 
> to get a given WADL ? I'd like to see if adding such property would 
> actually work or not

* Our schemas are located in seperated system interface projects. Thus they
are finally located in the *.war within the system interface *.jar in the
WEB-INF/lib folder.
* The schemas are referenced via relatives paths like <include
schemaLocation="folder/part.xsd" id="someSubXsd"/>
* For the JaxbProvider and WadlGenerator, we address the xsds by
"classpath:/xsd/ourSchema.xsd".
* The URI to access the overview of differnet wadls is
HOST:PORT/WEP_APP_ROOT_KEY/SERVLET?_wadl 
* The URI to access a specific jaxrs:server wadl is
HOST:PORT/WEP_APP_ROOT_KEY/SERVLET/JAXRS:SERVER@base?_wadl






--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753650.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 27/01/15 07:21, MayBee wrote:
> Hi Sergey,
>
> you are right. Thanks.
> I do not know what RestClient does in addition, but interestingly, the raw
> output includes attributes in the <application> root node, which also binds
> prefix1 namespace.
> What a nasty interface...
>
I suppose it may depend on whether it recognizes a given document 
format, etc...
> Last question would be the automatic resolution of xsd includes. Is there
> any way to automatically include all the referenced schemas from the root
> schema into the wadl?
Not really, it can be very difficult to do right without side-effects, 
there must a reason a given schema uses includes or imports so 
flattening it all may have side effects
> As currently the includes are transformed into
> includes with schemaLocation pointing to a non existent patch on the
> webserver.
> Is the only valid fix to configure redirects to the schemas for these
> addresses?
WADLGenerator will support such schema queries on its own, you can try 
it, but indeed, if you prefer the servlet container read them then 
redirects will do...
I can add a property to WADLGenerator to avoid updating the relative 
import/include references. Can you give some example of where your 
schemas are located, how is a root schema includes/imports one of them, 
and which URI you use (where is war context, servlet path in that URI) 
to get a given WADL ? I'd like to see if adding such property would 
actually work or not

Sergey
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753582.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Hi Sergey,

you are right. Thanks.
I do not know what RestClient does in addition, but interestingly, the raw
output includes attributes in the <application> root node, which also binds
prefix1 namespace.
What a nasty interface...

Last question would be the automatic resolution of xsd includes. Is there
any way to automatically include all the referenced schemas from the root
schema into the wadl? As currently the includes are transformed into
includes with schemaLocation pointing to a non existent patch on the
webserver.
Is the only valid fix to configure redirects to the schemas for these
addresses?



--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753582.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 26/01/15 16:22, MayBee wrote:
> Sergey Beryozkin wrote
>> Just get your browser show you the actual page content, after it has
>> displayed a _wadl query response, somewhere in the browser/View Menu
>
> I am working with Firefox RESTClient, just sending a GET-Requets for the
> ?_wadl address and I get the result as shown above. This is the plain body,
> without any browser interpretations.
Hmm... Are you saying that is is just "<application>" as a root name, 
without even any wadl namespaces there ? It can not be the case...
Please get RESTClient save the page to the disk and open with a text 
editor...

Sergey
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753559.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Sergey Beryozkin wrote
> Just get your browser show you the actual page content, after it has 
> displayed a _wadl query response, somewhere in the browser/View Menu

I am working with Firefox RESTClient, just sending a GET-Requets for the
?_wadl address and I get the result as shown above. This is the plain body,
without any browser interpretations.




--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753559.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 26/01/15 15:23, MayBee wrote:
> That is what I get with a GET-Request from the server using the *?_wadl
> address.
Just get your browser show you the actual page content, after it has 
displayed a _wadl query response, somewhere in the browser/View Menu
>
> What do you mean with page source? What should I check?
> To which point are your questions related? 1 or 2?
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753550.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
That is what I get with a GET-Request from the server using the *?_wadl
address.

What do you mean with page source? What should I check?
To which point are your questions related? 1 or 2?




--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753550.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
is it what the browser shows ? Can you select a Page source and check ?

Sergey

On 26/01/15 14:42, MayBee wrote:
> Ok, that are the normal semantics of a xml prefix I know.
> But then, the prefixes are currently unbound for the WADL.
>
> See, I get the following generated WADL with linked XSDs:
>
> <application>
> <grammars>
> <schema elementFormDefault="qualified"
> targetNamespace="http://host/myNamespace" version="1.0">
> ...
> </schema>
> <schema elementFormDefault="qualified"
> targetNamespace="http://host/myNamespace" version="1.0">
> ...
> </schema>
> </grammars>
> <resources base="http://localhost:8080/app/rest/service">
> <resource path="/">
> <resource path="myService">
> <method name="POST">
> <request>
> <representation mediaType="application/xml" element="prefix1:typeFromXsd"/>
> <representation mediaType="text/xml" element="prefix1:typeFromXsd"/>
> </request>
> <response>
> <representation mediaType="application/xml"/>
> </response>
> </method>
> </resource>
> </resources>
> </application>
>
> 1. 'prefix1' is not bound anywhere. So how can it refer to any of the xsd
> types?
>
> 2. includes of the referenced xsd schemas seems to be not resolved. I do not
> know whether this is necesssary, but I would suggest so. I currently only
> added the root schemas to the list of schemaLocations.
> Nevertheless, if I also add the XSDs referenced by the root XSDs into the
> list (at the end), I again do not get the original XSDs into my generated
> WADL, but the generated XSDs
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753546.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Ok, that are the normal semantics of a xml prefix I know.
But then, the prefixes are currently unbound for the WADL. 

See, I get the following generated WADL with linked XSDs:

<application>
<grammars>
<schema elementFormDefault="qualified"
targetNamespace="http://host/myNamespace" version="1.0">
...
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://host/myNamespace" version="1.0">
...
</schema>
</grammars>
<resources base="http://localhost:8080/app/rest/service">
<resource path="/">
<resource path="myService">
<method name="POST">
<request>
<representation mediaType="application/xml" element="prefix1:typeFromXsd"/>
<representation mediaType="text/xml" element="prefix1:typeFromXsd"/>
</request>
<response>
<representation mediaType="application/xml"/>
</response>
</method>
</resource>
</resources>
</application>

1. 'prefix1' is not bound anywhere. So how can it refer to any of the xsd
types?

2. includes of the referenced xsd schemas seems to be not resolved. I do not
know whether this is necesssary, but I would suggest so. I currently only
added the root schemas to the list of schemaLocations.
Nevertheless, if I also add the XSDs referenced by the root XSDs into the
list (at the end), I again do not get the original XSDs into my generated
WADL, but the generated XSDs





--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753546.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 26/01/15 14:02, MayBee wrote:
> Sergey Beryozkin wrote
>>>
>>> The prefix name does not affect the namespace binding at all.
>>> WADLGenerator will only use 'prefixN' if it auto-generates the grammar.
>>> However you can control that by having a package-level info where a
>>> preferred XMLSchema namespace prefix is set. WADLGenerator also has a
>>> 'namespacePrefix' property. This is all may needed only if you prefer to
>>> customize the auto generation process, no need to do it if you link to
>>> the external schemas
>
> Sry for the last mail... I wanted to just preview ;)
>
> I thought about the prefix referencing xsd types from any representation
> into the grammars. Therefore I have not understood the generated prefixes.
> Thus as I got you right, the prefixes in the representation@element
> declarations are non-sense and do not refer to any grammar?
>
They do. It just does not make a difference that the inlined schema may 
have different prefix names, because generally speaking the prefix names 
are just aliases which bind a given name to a given namespace
Sergey



> Kind Regards,
> Malte
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753543.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
Sergey Beryozkin wrote
>>
>>The prefix name does not affect the namespace binding at all.
>>WADLGenerator will only use 'prefixN' if it auto-generates the grammar. 
>>However you can control that by having a package-level info where a 
>>preferred XMLSchema namespace prefix is set. WADLGenerator also has a 
>>'namespacePrefix' property. This is all may needed only if you prefer to 
>>customize the auto generation process, no need to do it if you link to 
>>the external schemas

Sry for the last mail... I wanted to just preview ;)

I thought about the prefix referencing xsd types from any representation
into the grammars. Therefore I have not understood the generated prefixes.
Thus as I got you right, the prefixes in the representation@element
declarations are non-sense and do not refer to any grammar?

Kind Regards,
Malte




--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753543.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
>
>WADLGenerator needs to be told to avoid auto-generating the schemas, see
>
>http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-RepresentingexternalschemasandnonJAXBtypes
>
>Set a 'setSchemaLocations' property on WADLGenerator too. Having a 
>generator to introspect the setting of individual providers in order to 
>decide whether to auto-generate or not is really problematic

Done. Works. Thanks.

>
>The prefix name does not affect the namespace binding at all.
>WADLGenerator will only use 'prefixN' if it auto-generates the grammar. 
>However you can control that by having a package-level info where a 
>preferred XMLSchema namespace prefix is set. WADLGenerator also has a 
>'namespacePrefix' property. This is all may needed only if you prefer to 
>customize the auto generation process, no need to do it if you link to 
>the external schemas





--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753542.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 26/01/15 11:19, MayBee wrote:
> *What I have done:*
> 1. I added my root xsds to the jaxrs:schemaLocations list.
> 2. I created a JAXB Provider of type
> org.apache.cxf.jaxrs.provider.JAXBElementProvider, which also get the same
> list of schemaLocations as already specified in jaxrs:schemaLocations to
> enable xsd input validation.
Option 2. is sufficient, no need to use 1.

> 2.1. The JAXB Provider is than registered on the same jaxrs:server in the
> jaxrs:providers collection.
>
> *What I get:*
> I: A generated WADL, which contains a different xsd to my declarations in
> JAXB Provider & jaxrs:schemaLocations. It seems to be reconstructed from the
> JAXB Objects.
WADLGenerator needs to be told to avoid auto-generating the schemas, see

http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-RepresentingexternalschemasandnonJAXBtypes

Set a 'setSchemaLocations' property on WADLGenerator too. Having a 
generator to introspect the setting of individual providers in order to 
decide whether to auto-generate or not is really problematic


>
> II: Furthermore, I get the xsd with namespace prefix "A" and my request and
> response parameter types are of prefix "prefix1", which does not relate to
> any xsd element declaration in the WADL.
>
The prefix name does not affect the namespace binding at all.
WADLGenerator will only use 'prefixN' if it auto-generates the grammar. 
However you can control that by having a package-level info where a 
preferred XMLSchema namespace prefix is set. WADLGenerator also has a 
'namespacePrefix' property. This is all may needed only if you prefer to 
customize the auto generation process, no need to do it if you link to 
the external schemas

Sergey
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753526.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: included xsd's are not resolved for wadl generation

Posted by MayBee <ma...@gmx.de>.
*What I have done:*
1. I added my root xsds to the jaxrs:schemaLocations list.
2. I created a JAXB Provider of type
org.apache.cxf.jaxrs.provider.JAXBElementProvider, which also get the same
list of schemaLocations as already specified in jaxrs:schemaLocations to
enable xsd input validation.
2.1. The JAXB Provider is than registered on the same jaxrs:server in the
jaxrs:providers collection.

*What I get:*
I: A generated WADL, which contains a different xsd to my declarations in
JAXB Provider & jaxrs:schemaLocations. It seems to be reconstructed from the
JAXB Objects.

II: Furthermore, I get the xsd with namespace prefix "A" and my request and
response parameter types are of prefix "prefix1", which does not relate to
any xsd element declaration in the WADL.



--
View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451p5753526.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: included xsd's are not resolved for wadl generation

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 23/01/15 14:05, MayBee wrote:
> Hi again,
>
> I have found the following in this documentation:
> https://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-RepresentingexternalschemasandnonJAXBtypes
>
>> TODO : add ignoreImports flag so that users can list root and imported
>> schemas in "schemaLocations" and have them all inlined.
I vaguely recall I had an idea while I was typing the documentation that 
it might be good if all the schemas imported directly or indirectly
can be inlined. Not sure now to be honest if it makes sense after all.
They do not have to be inlined for WADL offer a correct description.

>
> What is the current state here? Under progress? Any target version?
> At a first glance, I could not find an "ignoreImports" property for the
> JAXBElementProvider so provide my included schemas by hand by the
> "schemaLocations" list.
>
This is related to WADLGenerator.

WADL generator shoud be able to return schemas on request.
Example, if you have a base at localhost:8080/bar and a grammar 
importing schemas/bar.xsd then a subsequent

localhost:8080/bar/schemas/bar.xsd

should work, I think I have some tests for it...

Sergey


> Regards,
> Malte
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/included-xsd-s-are-not-resolved-for-wadl-generation-tp5753451.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com