None of the examples I've seen have had to do that. Even the "basic" sample
in cxf doesn't seem to do that. If I look at the sample
Customer/Order/Product classes none of them have an explicit namespace
declaration.

I gave it a try anyways :

    @XmlRootElement(namespace = "http://example.com/test";)
    public static class TestCompositeObject
    {
        public int id = 23;
        public String name = "asdf";
    }

I can see wadl has changed to have the namespace for the
TestCompositeObject entry. The method itself though has not changed :

<resource path="/setTest3">
   <method name="PUT" id="setTest3">
      <request>
         <representation mediaType="application/xml"/>
      </request>
      <response>
         <representation mediaType="application/xml"/>
      </response>
   </method>
</resource>

When I call wadl2java on it, I get an exception : (I'm using jdk
1.6.0_26-b03 on linux, and cxf 2.6.0)

     [java] WADLToJava Error: java.lang.reflect.UndeclaredThrowableException
     [java]
     [java] org.apache.cxf.tools.common.ToolException:
java.lang.reflect.UndeclaredThrowableException
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:82)
     [java]     at
org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
     [java]     at
org.apache.cxf.tools.wadlto.WADLToJava.run(WADLToJava.java:65)
     [java]     at
org.apache.cxf.tools.wadlto.WADLToJava.run(WADLToJava.java:57)
     [java]     at
org.apache.cxf.tools.wadlto.WADLToJava.main(WADLToJava.java:99)
     [java] Caused by: java.lang.reflect.UndeclaredThrowableException
     [java]     at $Proxy9.bind(Unknown Source)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.SourceGenerator.createCodeModel(SourceGenerator.java:1196)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.SourceGenerator.generateSchemaCodeAndInfo(SourceGenerator.java:231)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.SourceGenerator.generateSource(SourceGenerator.java:220)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.processWadl(JAXRSContainer.java:151)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:65)
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:74)
     [java]     ... 4 more
     [java] Caused by: java.lang.reflect.InvocationTargetException
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
     [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at
org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:52)
     [java]     ... 11 more
     [java] Caused by: java.lang.reflect.UndeclaredThrowableException
     [java]     at $Proxy13.error(Unknown Source)
     [java]     at
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:316)
     [java]     at
com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:82)
     [java]     at
com.sun.xml.xsom.impl.parser.ParserContext$2.error(ParserContext.java:206)
     [java]     at
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:184)
     [java]     at
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
     [java]     at
com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
     [java]     at
com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:85)
     [java]     at co
     [java]
m.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:135)
     [java]     at
com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:211)
     [java]     at
com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:532)
     [java]     at
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:268)
     [java]     ... 16 more
     [java] Caused by: java.lang.reflect.InvocationTargetException
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
     [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at
org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:52)
     [java]     ... 28 more
     [java] Caused by: java.lang.RuntimeException: Error compiling schema
from WADL : undefined simple or complex type 'testCompositeObject'
     [java]     at
org.apache.cxf.tools.wadlto.jaxrs.SourceGenerator$InnerErrorListener.error(SourceGenerator.java:1343)
     [java]     ... 33 more
     [java] Caused by: org.xml.sax.SAXParseException: undefined simple or
complex type 'testCompositeObject'
     [java]     at
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
     [java]     ... 23 more


I should add though, if I just get the object like :

    @GET
    @Path("setTest2")
    @Produces("application/xml")
    public TestCompositeObject getTest2()
    {
        return(new TestCompositeObject());
    }

It does return XML as a string like I expect it to.



On Thu, May 10, 2012 at 7:15 PM, Sergey Beryozkin <[email protected]>wrote:

> Hi
>
> On 10/05/12 04:37, Ted wrote:
>
>> thanks for the answer to my previous method Id problem, adding
>> addResourceAndMethodIds worked great.
>>
>> I have a new problem now, I'm trying to use the JAXB to automatically
>> convert parameters and response types to and from java/xml. The method
>> parameter seems to be dissappearing, or I'm missing an annotation or
>> something. All the examples I've seen and documentation seems to show that
>> it should work...
>>
>> My service has the following :
>>
>>     @XmlRootElement
>>     public static class TestCompositeObject
>>     {
>>         public int id = 23;
>>         public String name = "asdf";
>>     }
>>
>>     @PUT
>>     @Path("setTest3")
>>     @Produces("application/xml")
>>     @Consumes("application/xml")
>>     public TestCompositeObject setTest3(TestCompositeObject transfer)
>>     {
>>         logger.info(transfer);
>>         return(transfer);
>>     }
>>
>> The wadl generated looks a little off, it's missing the params :
>>
>>             <resource path="/setTest3">
>>                 <method name="PUT" id="setTest3">
>>                     <request>
>>                         <representation mediaType="application/xml" />
>>                     </request>
>>                     <response>
>>                         <representation mediaType="application/xml" />
>>                     </response>
>>                 </method>
>>             </resource>
>>
>> As a result when I generate the stubs from the wadl, it comes out not
>> quite
>> right :
>>
>>     @PUT
>>     @Consumes("application/xml")
>>     @Produces("application/xml")
>>     @Path("/setTest3")
>>     Response setTest3();
>>
>> There's no method parameter, and I'm not quite sure if Response should be
>> the return type of if it should have been mapped back to
>> TestCompositeObject.
>>
>> I can't seem to find any documentation on any annotations or any
>> configuration to sort this out.
>>
>>
> The explanation is that TestCompositeObject has no any namespace bound to
> it, please add a namespace attribute to XMlRootElement and you should get
> the grammar and links properly generated
>
> HTH
> Sergey
>
>
>  Anyone have any ideas?
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>



-- 
Ted.

Reply via email to