码迷,mamicode.com
首页 > 其他好文 > 详细

CXF WADL generation

时间:2014-07-02 06:31:19      阅读:549      评论:0      收藏:0      [点我收藏+]

标签:cxf   wadl   

Problem1: There is no grammar information generated in wadl

Cause:

org.apache.cxf.jaxrs.model.wadl.WadlGeneratorrelies on org.apache.cxf.jaxrs.utils.ResourceUtils

to create a JAXBContext, without a JAXBContext, no grammar section will be generated

JAXB is not printing stack trace for any problem

LOG.fine("No JAXB context can becreated");

 

 

Error  pattern

Cause

Example

Solution

Two classes have the same XML type name  "xxx". Use @XmlType.name and @XmlType.namespace to assign different  names to them.

Two properties are with the same class  name, but the classes are of different type

In class CustomerContactsRequest

@XmlElement(name = "name")

private ContactName name;

The ContactName is an inner static class  of CustomerContactsRequest

 

In class CustomerContactsV2Request

@XmlElement(name = "name")

private ContactName name;

The ContactName is an inner static class  of CustomerContactsV2Request

Use @XmlType.name and @XmlType.namespace  to differentiate the 2 inner classes

Xxx is a non-static inner class, and JAXB  can‘t handle those.

Use an inner class that is non-static

In class  UpdateCustomerPaymentInstrumentDetails

There is an inner class

public class UpdateCreditCardDetails  that is non-static

Make the class a static inner class

















 

 

Problem2: Generated grammar is not associated with resource method‘s request andresponse  

Cause:

We need a namespace, without namespace, it cannot associate request response with xsd types declared in the grammar section

See org.apache.cxf.jaxrs.model.wadl.WadlGenerator.generateQName

 

There are two ways of declare a namespace:

XmlRootElement(namespace=xxx)   at class level

XmlSchema  (namespace=xxx) at packagelevel

 


CXF WADL generation,布布扣,bubuko.com

CXF WADL generation

标签:cxf   wadl   

原文地址:http://shadowisper.blog.51cto.com/3189863/1433028

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!