cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Diephouse <...@envoisolutions.com>
Subject Re: Get schema types from JAXB?
Date Thu, 28 Sep 2006 02:47:11 GMT
Hi Jim,

Thanks for the insight! Kind of sucks we need to use the com.sun classes 
to do this, but I don't think anyone is writing another JAXB 
implementation anytime soon...

- Dan

Jim Ma wrote:
> Hi Dan ,
>
> You can use the TypeReference to name the schema element .  Following
> snippet can generate schema  for your sample  with SUN's JAXB impl :
>
>         import com.sun.xml.bind.api.JAXBRIContext;
>         import com.sun.xml.bind.api.TypeReference;
>
>         QName qname = new QName("http://www.apache.org", "outTest");
>
>         Annotation anno = paramsAnno;  // Can not be null, can be any,  JAXB
> only handle the XMLJavaTypeAdapter annotation
>
>         TypeReference typeref = new TypeReference(qname, String.class,
> anno);
>
>        java.util.List<TypeReference> types = new
> java.util.ArrayList<TypeReference>();
>
>         types.add(typeref);
>         Class[] classes = new Class[]{String.class};
>
>         try {
>             JAXBRIContext context = JAXBRIContext.newInstance(classes,
> types,"http://www.apache.org", false);
>             context.generateSchema(new SchemaOutputResolver());
>         } catch (JAXBException e2) {
>             e2.printStackTrace();
>         }
>
>
>
> Cheers
>
> Jim
>
>
>   
>> -----Original Message-----
>> From: Dan Diephouse [mailto:dan@envoisolutions.com]
>> Sent: Wednesday, September 27, 2006 10:17 PM
>> To: cxf-dev@incubator.apache.org
>> Subject: Re: Get schema types from JAXB?
>>
>>
>> So lets say we have a service with the method:
>>
>> @WebResult(name="outText")  String echo(@WebParam(name="inText") String
>> inText);
>>
>> Somehow we need to translate this into:
>> <schema>
>>   <element name="inText" type="xsd:string"/>
>>   <element name="outText" type="xsd:string"/>
>> </schema>
>>
>> You're telling me JAXB can do that? How? It can't read the JSR181
>> annotations, so how would it know what they're named? Obviously it must
>> be possible as Celtix does java2wsdl, but I'm a bit confused as to how.
>> Can you maybe shed some more light on this?
>>
>> - Dan
>>
>> Jim Ma wrote:
>>     
>>> Hi Dan,
>>>
>>> I have not found there is an api can get the schema type in the JAXB .
>>> Celtix do not need the schema type information for every class.
>>>
>>> Celtix tool use JAXB to generate schema file first , then include this
>>> schema file in the generated wsdl .
>>>
>>> Jim
>>>
>>>
>>>       
>>>> -----Original Message-----
>>>> From: Dan Diephouse [mailto:dan@envoisolutions.com]
>>>> Sent: Wednesday, September 27, 2006 4:53 AM
>>>> To: Daniel Kulp
>>>> Cc: cxf-dev@incubator.apache.org
>>>> Subject: Re: Get schema types from JAXB?
>>>>
>>>>
>>>> Daniel Kulp wrote:
>>>>
>>>>         
>>>>> Dan,
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> Anyone know if there is a way to get the schema type names
>>>>>>
>>>>>>             
>>>> from JAXB for
>>>>
>>>>         
>>>>>> a particular class? In XFire we always used Aegis for non JAXB
>>>>>>
>>>>>>             
>>>> types and
>>>>
>>>>         
>>>>>> we wrote some code to read the xml type names from the
>>>>>>             
>> annotations too.
>>     
>>>>>> I don't see anything that covers all the bases in the JAXB
>>>>>>
>>>>>>             
>>>> apis - so I'm
>>>>
>>>>         
>>>>>> wondering what Celtix did.
>>>>>>
>>>>>>
>>>>>>             
>>>>> I don't think we have anything cause I don't think Celtix ever
>>>>>
>>>>>           
>>>> NEEDED that
>>>>
>>>>         
>>>>> functionality/information.   What's the use case?
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> Basically I'm looking for something that
>>>>>> returns "xsd:string" when I give it a String.class.
>>>>>>
>>>>>>
>>>>>>             
>>>>> Well, the problem is, String.class can also map to
>>>>>
>>>>>           
>>>> xsd:normalizedString or
>>>>
>>>>         
>>>>> some of the SimpleType restrictions.   Thus, that's not reliable.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> Use case is we're taking a class and generating a WSDL for it. To do
>>>> this you have to figure out what the schema types are of the operation
>>>> parameters.
>>>>
>>>> - Dan
>>>>
>>>> --
>>>> Dan Diephouse
>>>> Envoi Solutions
>>>> http://envoisolutions.com
>>>> http://netzooid.com/blog
>>>>
>>>>
>>>>         
>>>       
>> --
>> Dan Diephouse
>> Envoi Solutions
>> http://envoisolutions.com
>> http://netzooid.com/blog
>>
>>     
>
>   


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com
http://netzooid.com/blog


Mime
View raw message