moxy

How to bind a xml element into an object member variable?

北城以北 提交于 2019-12-01 05:03:20
问题 I'm trying to unmarshal an xml to an object using moxy.Below is the sample of the xml. <root> <name> <firstname>value</firstname> </name> <address>value of address</address> </root> And below is the class I'm trying to map. import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.eclipse.persistence.oxm.annotations.XmlPath; @XmlRootElement(name=

PropertyException when setting Marshaller property with eclipselink.media-type value: application/json

纵饮孤独 提交于 2019-12-01 05:01:27
问题 I'm attempting to follow the example located here but get an javax.xml.bind.PropertyException. I receive this exception because of the following line of code: marshaller.setProperty("eclipselink.media-type", "application/json"); I have literally copy/pasted the example listed above so my code is exactly what you see there. Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help. Any help would be most appreciated, (de)serialization

JAXBContext, jaxb.properties and moxy

不羁岁月 提交于 2019-12-01 04:55:12
问题 The jaxb.properties needs to be in the same package as the domain classes you are creating the JAXBContext on. I am using Moxy's xml driven configuration since I doesn't want to use annotations or XJC generated objects. I have an existing domain classes that are spread across multiple packages. Does this mean that i need to have the jaxb.properties present in all those packages or there is a better alternative (Maybe writing my own implementation of some interface that can read from a jvm arg

Is there a possibility to hide the “@type” entry when marshalling subclasses to JSON using EclipseLink MOXy (JAXB)?

╄→гoц情女王★ 提交于 2019-12-01 04:06:37
问题 I'm about to develop a JAX-RS based RESTful web service and I use MOXy (JAXB) in order to automatically generate my web service's JSON responses. Everything is cool, but due to the fact that the web service will be the back-end of a JavaScript-based web application and therefore publicly accessible I don't want to expose certain details like class names, etc. But, I've realized that under certain conditions MOXy embeds a "@type" entry into the marshalled string and this entry is followed by

NPE Thrown Marshalling Entity in JAX-RS

烈酒焚心 提交于 2019-12-01 03:58:45
问题 I have a JAX-RS webservice that makes use of JPA entity classes. I have a resource class like this: @Path("/entity") public class MyEntityResource { @GET @Produces(MediaType.APPLICATION_XML) @Path("/{entity}") public MyEntity getMyEntity(@PathParam("entity") String entity) { log.debug("Entering getMyEntity with param: " + entity); MyEntity entityObject = genericService.find(MyEntity.class, entity); if (entityObject == null) { log.debug("Entity not found."); throw new WebApplicationException

eclipselink/Moxy : inheritance and attribute name oveloading based on type

我们两清 提交于 2019-12-01 02:13:31
问题 I'm facing a marshalling/unmarshalling problem involving inheritance and polymorphism using MOXy's JAXB implementation and external metadata bindings file. I have no control on the XML files or the model classes. There are multiple classes inside the model that inherit other DTO classes. Here is an example of the environment I'm working in. This example is only here for some syntax purpose, the real environment involves nested inheritance, collections etc. : Here is the class that will be

Using @XmlPath with jaxb/MOXy to map complex type

ε祈祈猫儿з 提交于 2019-12-01 00:54:08
I have a deep XML structure with a lot of pointless wrappers I'm mapping to a single Java class. Mapping the simple datatypes with @XmlPath is a walk in the park, but when it comes to types that actually require their own class I'm not quite sure how to do it, especially when those types should be put in a list as well. I'm having problems to map all the element types in the below example to my Element class. Since the elements wrapper resides in resource which is mapped using @XmlPath I can not use the @XmlElementWrapper , which would otherwise be the way I usually would do this. Example XML

Jax-WS - To Remove Empty Tags from Request XML

ⅰ亾dé卋堺 提交于 2019-11-30 22:16:29
I'm trying to consume a web service exposed by a provider. The Provider has a strict checking at his end that the request xml should not contain tags which don't have values. I'm using Jax-WS. If i don't set value in a particular object, it is being sent as empty tag and the tag is present. PFB the example illustrating my issue. Client XML : <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:host="http://host.testing.webservice.com/"> <soapenv:Header/> <soapenv:Body> <host:testingMathod> <arg0> <PInfo> <IAge>45</IAge> <strName>Danny</strName> </PInfo> <strCorrId

Unmarshalling nested objects from JSON with JAXB

空扰寡人 提交于 2019-11-30 22:10:22
I'm trying to unmarshall input JSON into JAXB objects with Eclipselink. However, when I try to do this, I find that nested objects end up being set as null. I can try and unmarshall the nested object by itself, and it will work up until the point that it has to unmarshall a further nested object, which is also then set to null. For example, take this class: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "event", propOrder = { "objectBs" }) public class ObjectA implements Serializable { private final static long serialVersionUID = 56347348765454329L; @XmlElement(required = true)

Unmarshalling nested objects from JSON with JAXB

旧城冷巷雨未停 提交于 2019-11-30 17:37:57
问题 I'm trying to unmarshall input JSON into JAXB objects with Eclipselink. However, when I try to do this, I find that nested objects end up being set as null. I can try and unmarshall the nested object by itself, and it will work up until the point that it has to unmarshall a further nested object, which is also then set to null. For example, take this class: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "event", propOrder = { "objectBs" }) public class ObjectA implements Serializable {