moxy

Jax-WS - To Remove Empty Tags from Request XML

你。 提交于 2019-11-30 17:21:41
问题 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

Where to include jaxb.properties file?

风流意气都作罢 提交于 2019-11-30 17:17:25
I have REST (Jersey) webservice that makes use of some data objects that are marshalled/unmarshalled to/from XML. The data objects are in a separate project/jar that the webservice war depends on. I'm using MOXy as my JAXB implementation since I'm deploying to Glassfish and that's already included. I know I need a jaxb.properties file to set the JAXB implementation to MOXy with this entry: javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory The question is, should the jaxb.properties file be included in the data object jar or in the webservice war or both? You

JAXB @XmlAdapter: Map -> List adapter? (marshall only)

穿精又带淫゛_ 提交于 2019-11-30 13:29:40
I have a Map<String, String> . The first idea everyone has is to convert it to a List<Pair<String,String>> ( Pair being a custom class). I've tried a @XmlAdapter like this: public class MapPropertiesAdapter extends XmlAdapter<List<Property>, Map<String,String>> { ... } But Eclipse MOXy, the JAXB impl I use, ended up with a ClassCastException - "can't convert HashMap to Collection". Is this conversion supported by JAXB? Or did I overlook some documentation part which explains why it isn't? PS: I wanted to get XML like this: <properties> <property name="protocol"/> <property name="marshaller"/>

Can I replace jaxb.properties with code?

孤人 提交于 2019-11-30 09:22:01
I am using some non-standard extensions from EclipseLink's implementation of JAXB, and to enable that implementation, I have to configure it using jaxb.properties. Works well. However, due to a build error, the properties file was not included in the proper place, resulting in the default JAXB being used, which without any errors just continued to parse the XML file, ignoring the non-standard extension, leaving me with a non-working bean. To make this more robust, I'd like to get rid off the properties file and specify the context configuration in code. I already have a compile-time dependency

MOXy deserialization exception: A descriptor with default root element was not found in the project

流过昼夜 提交于 2019-11-30 09:00:40
问题 Here are my classes: @XmlRootElement(name="Zoo") class Zoo { //@XmlElementRef public Collection<? extends Animal> animals; } @XmlAccessorType(XmlAccessType.FIELD) @XmlSeeAlso({Bird.class, Cat.class, Dog.class}) @XmlDiscriminatorNode("@type") abstract class Animal { @XmlElement public String name; } @XmlDiscriminatorValue("Bird") @XmlRootElement(name="Bird") class Bird extends Animal { @XmlElement public String wingSpan; @XmlElement public String preferredFood; } @XmlDiscriminatorValue("Cat")

Where to include jaxb.properties file?

旧巷老猫 提交于 2019-11-30 00:51:50
问题 I have REST (Jersey) webservice that makes use of some data objects that are marshalled/unmarshalled to/from XML. The data objects are in a separate project/jar that the webservice war depends on. I'm using MOXy as my JAXB implementation since I'm deploying to Glassfish and that's already included. I know I need a jaxb.properties file to set the JAXB implementation to MOXy with this entry: javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory The question is, should

How to use Moxy XPath annotated beans in web services?

余生长醉 提交于 2019-11-29 16:37:26
I have a bean @XmlRootElement(name = "alpha") public class MyBean { private String thetaValue; @XmlPath("beta/theta/text()") public String getThetaValue() { return this.thetaValue; } public void setThetaValue(String thetaValue) { this.thetaValue = thetaValue; } } This is annotated using eclipselink moxy jaxb. I want to use the same bean and Xpath to host a web service. How do I do this? the web service will be hosted on tomcat 6 or 7 There isn't a standards based integration point between JAX-WS (JSR-224) and JAXB (JSR-222) implementations. This means support for EclipseLink MOXy as the JAXB

(moxy) jaxb marshaling and hibernate proxy objects

笑着哭i 提交于 2019-11-29 14:02:58
In the last couple of days I have tried to make support for XML marshalling/unmarshalling of a Hibernate model, using MOXy JAXB. Trying to do this, I have run into a problem with hibernates proxy objects. Consider something like: public class User { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "address") public Address getAddress() { return address; } } public abstract class Address { // Something } public class CoolAddress extends Address { public String getSomething() { return something; } } I have tried to map this code using MOXy JAXB in the following way: @XmlAccessorType

Customizing JSON marhsalling with GlassFish v4

落花浮王杯 提交于 2019-11-29 10:51:12
We've got a JAX-RS application that runs on Apache TomEE. We slightly customize the default Jettison provider to better adhere to JSON conventions used by JavaScript frontend. TomEE allows to do it via its resources.xml file: <resources> <Service id="jettison" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider"> serializeAsArray = true dropRootElement = false arrayKeys = members,roles supportUnwrapped = true writeXsiType = false </Service> </resources> Now we are migrating to GlassFish v4.1, and we notice that JSON output differs from what we had in TomEE - thus completely breaking

Remove “type” from JSON output jersey moxy

落花浮王杯 提交于 2019-11-29 09:59:38
How to remove the type from the JSON output that I have. I have a class/bean that contains output of a REST service.I'm using jersey-media-moxy to do the conversion. The service @Resource public interface MyBeanResource { @GET @Path("/example") @Produces( MediaType.APPLICATION_JSON ) public Bean getBean(); } The Bean @XmlRootElement class Bean { String a; } I want to add some functionality (for initializing the bean using the constructor) class BeanImpl extends Bean { BeanImpl(OtherClass c) { a = c.toString() } } The outputted JSON is: {type:"beanImpl", a:"somevalue"} I do not want the type in