jaxb

Is it possible to use @XmlInverseReference where object and property are of same type?

前提是你 提交于 2020-01-24 13:08:08
问题 I'm using the MOXy JAXB implementation and make quite extensive use of the @XmlInverseReference annotation. However, I've recently encountered a scenario where this approach doesn't seem to work. If I have a class containing a field with a property that's the same type as the parent class, applying @XmlInverseReference seems to suppress the marshalling of that property altogether. Omitting the annotation yields a predictable StackoverflowException. Has anybody encountered this problem and

XmlAdapter for base64Binary results in String

我是研究僧i 提交于 2020-01-24 11:10:07
问题 I've an XSD file containing this: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" elementFormDefault="qualified" targetNamespace="http://example.org/"> <xsd:complexType name="Certificate"> <xsd:sequence> <xsd:element name="certificate" type="xsd:base64Binary"> <xsd:annotation> <xsd:appinfo> <xjc:javaType name="java.security.cert.X509Certificate" adapter=

JAXB - Example of following a keyref when unmarshalling

笑着哭i 提交于 2020-01-24 10:51:26
问题 According to this, you can make use of xs:key and xs:keyref when marshalling and unmarshalling data in JAXB 2.x. However, I can't find a working example of this being done anywhere. What we're doing is setting a lookup section in each XML message containing the details for the reference/code values (id, name, description, etc), and then have the data elements later in the message refer back to these items using their key. XML schema defines and supports this through xs:keyref and xs:key (xs

Glassfish 5 ignores JAXB @XmlJavaTypeAdapter annotation?

谁说胖子不能爱 提交于 2020-01-24 09:06:32
问题 I just switched to Glassfish 5 from Glassfish 4 and I noticed that Glassfish no longer called the unmarshal method of my DateTimeAdapter class, it worked okay in Glassfish 4. The Web service class receives a json data and it should be converted automatically to the appropriate RegisterItemDTO object. I've tried putting the annotation on the getter method and it still didn't work. The unmarshal method was never called. I've made sure the json data was in the right format. Service class:

Glassfish 5 ignores JAXB @XmlJavaTypeAdapter annotation?

核能气质少年 提交于 2020-01-24 09:05:49
问题 I just switched to Glassfish 5 from Glassfish 4 and I noticed that Glassfish no longer called the unmarshal method of my DateTimeAdapter class, it worked okay in Glassfish 4. The Web service class receives a json data and it should be converted automatically to the appropriate RegisterItemDTO object. I've tried putting the annotation on the getter method and it still didn't work. The unmarshal method was never called. I've made sure the json data was in the right format. Service class:

Jackson JSON generates HTTP status 500, XML works

一笑奈何 提交于 2020-01-23 17:53:31
问题 I am currently using Jackson to serialize Java objects to JSON and XML as the response for a REST webservice. I have the following annotated Java object: @XmlRootElement(name = "Product") @XmlAccessorType(XmlAccessType.FIELD) public class ProductDetailsView { @XmlElement private int id; @XmlElement private long EAN; @XmlElement private String manufacturer; @XmlElement private String modelname; @XmlElementWrapper(name = "onlineCompetitors") @XmlElement(name = "competitor") private List

Jackson JSON generates HTTP status 500, XML works

大兔子大兔子 提交于 2020-01-23 17:52:59
问题 I am currently using Jackson to serialize Java objects to JSON and XML as the response for a REST webservice. I have the following annotated Java object: @XmlRootElement(name = "Product") @XmlAccessorType(XmlAccessType.FIELD) public class ProductDetailsView { @XmlElement private int id; @XmlElement private long EAN; @XmlElement private String manufacturer; @XmlElement private String modelname; @XmlElementWrapper(name = "onlineCompetitors") @XmlElement(name = "competitor") private List

Create Null Object Unmarshalling Empty Element with JAXB

南楼画角 提交于 2020-01-23 17:10:14
问题 I am using JAXB (EclipseLink implementation) in a JAX-RS webservice. When an empty element is passed in the XML request an empty object is created. Is it possible to set JAXB to create a null object instead? Example XML: <RootEntity> <AttributeOne>someText</AttributeOne> <EntityOne id="objectID" /> <EntityTwo /> </RootEntity> When unmarshalling, an instance of EntityOne is created and the id attribute set to "objectID" and an instance of EntityTwo is created with null attributes. Instead I

Validation for generated JAXB Classes (JSR 303 / Spring)

…衆ロ難τιáo~ 提交于 2020-01-22 19:22:27
问题 I Generated domain objects from schema (request & response) using JAXB (maven-jaxb2-plugin) I would like add validations (notnull /empty) for couple of attributes. I would like to have custom Bean Validation, the application is a REST service, i'm using Spring 3 and JSR 303 but i dont think i can use JSR 303 to validate the object as it is generated from the schema. can someone give me a nudge in the right direction on how to get this done. 回答1: We've been using the Krasa JAXB plugin to

cxf: generate jaxb constructor with arguments

依然范特西╮ 提交于 2020-01-22 05:56:13
问题 Is there a way in CXF to generate JAXB classes with full constructors (i.e., with the members of the class as arguments)? 回答1: Use the value-constructor xjc plugin. Maven snippet: <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <defaultOptions> <extraargs> <extraarg>-xjc-Xvalue-constructor</extraarg> </extraargs> <