jaxb

JAXB 2.0 - How to skip processing of nodes and return them as a String

Hello, I am processing XML documents with JAXB 2.0 where I need information(in my example 'id') mapped to Java objects and run some business logic with. Everything works fine here. But these XML documents always hold a collection of approximately 500 nodes that I just want to save to a database in the original xml format, so I am jus...

JAXB and Jersey list resolution?

I have the following XSD defined to generate some jaxb objects. It works well. <xsd:element name="Person" type="Person" /> <xsd:complexType name="Person"> <xsd:sequence> <xsd:element name="Id" type="xsd:int" /> <xsd:element name="firstName" type="xsd:string" /> <xsd:element name="lastName" type="xsd:string" ...

JAX-RS Element name for return type Collection

I have a situation where the method signature of JAX-RS service looks like... public Collection<CustomerData> getCustomers() { ... } The xml generated has the root tag like customerDatas as below <customerDatas><customer>.....</customer></customerDatas> I am using JAXB annotations and root element name for CustomerData is custom...

How can I make a WebMethod parameter required

We use the "start from Java" approach to creating JAX-WS 2.0 web services using the Metro 1.5 stack. When we point a standard tool like SoapUI at one of our web services it indicates that parameters to WebMethods are optional. The generated xsd shows minOccurs=0. I need a way to make WebMethod parameters required (maybe minOccurs=1 in...

Writing a REST wrapper over AXIS2

Hi, I have an AXIS2 webservice already in place for my application. However, for an android mobile client, SOAP based webservices are too heavy. Hence, I am planning to wrap this webservice into RESTful webservice. To do this, 1. I ran wsimport on my wsdl to generate jaxb sources, since the ones I had were AXIS2 generated(with ADB). ...

XML Schema Creation Error - What is JAXB Doing?!

Hey guys, I'm working on a project that involves a simple web service, and have had a slew of little problems. It's an Apache CXF webservice (using JAX-WS, over SOAP). The service itself is pretty simple: receive a request, insert the request into a database, and return whether the insert was successful. I'd like to rely on XML validat...

Customize JAXB 2.0 generated method names from a xsd:choice element

Hello everybody, I'm trying to figure out how to customize a method name that's being generated by JAXB 2.1.12. I have an epic XML schema (that is not in my control), and it contains a group with a choice element that contains about 200 other elements. So when I'm generating the JAXB classes, the get() method that is created is rather un...

CXF and Validation - Schema Restrictions Ignored

Hey guys, I've been working on a CXF web service and have had some trouble. With the help of SO, I've got my service validating against a fairly complex schema- a requirement of the project. I've noticed some weird issues with the validation, however. While datatypes are validated- eg, a random alphanumeric string instead of a date i...

Bean-To-XML annotations: how to process nested structure

For bean->xml convertion in webservices we use Aegis from CXF (it is jaxb-compatible, as I understand). This is my type: class C{ private int a; private int b; private T t; ... } class T{ private int t1; private int t2; } I need t.t1 field to be on the same level in XML as a and b in C (bean restored from xml should be like this: ...

Unmarshalling a list using JAXB

Hi everyone. I know this is a beginner question, but I've been banging my head against a wall for two hours now trying to figure this out. I've got XML coming back from a REST service (Windows Azure Management API) that looks like the following: <HostedServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www....

Help with XSD element having references to other elements but don't want things nested.

I have a XSD file I'm using to generate JAXB classes for a RESTful API I am working on. I have two classes. An Appointment and a Person. A Person has an Appointment. I'd like to end up with XML like this: <Appointment> <Person id="12345">Billy Bob</Person> ... </Appointment> So, that on the far end I an just fetch Person if...

JAXB: How to avoid repeated namespace definition for xmlns:xsi

I have a JAXB setup where I use a @XmlJavaTypeAdapter to replace objects of type Person with objects of type PersonRef that only contains the person's UUID. This works perfectly fine. However, the generated XML redeclares the same namespace (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") every time it's used. While this is genera...

JAXB Marshalling Objects with java.lang.Object field

I'm trying to marshal an object that has an Object as one of its fields. @XmlRootElement public class TaskInstance implements Serializable { ... private Object dataObject; ... } The dataObject can be one of many different unknown types, so specifying each somewhere is not only impractical but impossible. When I try to marsha...

JAXB IDREF and ID usage?

I'm looking to write an XSD which will be used to generate some Java classes via JAXB. I'd like the resulting XML to look like this: <Appointment> <Patient ref="12345">Bob Smith</Patient> <Type>Some Appointment Type</Type> <Date>2010-02-17</Date> .... </Appointment> So, given this schema I'm wanting it to generate a c...

How do you marshall a parameterized type with JAX-WS / JAXB?

Consider the following classes (please assume public getter and setter methods for the private fields). // contains a bunch of properties public abstract class Person { private String name; } // adds some properties specific to teachers public class Teacher extends Person { private int salary; } // adds some properties specific to stu...

Multiple XML mappings for the same Java object using JAXB?

Note: Editing this to rephrase it around JAXB in hopes of getting new answers. I'm using CXF, but it's using JAXB for the mappings. I've got a POJO model. Right now I have it mapped via annotations and using JAXB to spew/read XML. However that's only one XML format and I need to map that POJO model to one of various XML formats dependin...

Best ways to manage generated artifacts for web service/xml bindings in a java webapp/client?

I'm working on a couple of web services that use JAXB bindings for the messages (in JAX-WS or spring-ws). When using these bindings there's always some code that is automatically generated from the WSDL to bind the message objects. I'm struggling to figure out the best way I can make this work so that it's easy to work with, hard to brea...

JAXB xsd to object binding error

I got error while binding the xml schema int Java Object by using the JAXB complier XJC ..I got the following error.. C:\Siva\jaxbw-plugin\lib>java -jar jaxb-xjc.jar xjc -p C:\Siva\jars\test.jaxb C: \Siva\jars\Emp.xsd -d C:\Siva\jars\objects parsing a schema... [ERROR] C:\Siva\jaxbw-plugin\lib\xjc (The system cannot find the file specif...

JAXB: Unmarshalling does not always populate certain classes?

Hello, I have a JAXB class generation problem I was hoping to get some help with. Here's the part of the XML that is the source of my problem... Code: <xs:complexType name="IDType"> <xs:choice minOccurs="0" maxOccurs="2"> <xs:element name="DriversLicense" minOccurs="0" maxOccurs="1" type="an..35" /> <xs:element name="SSN"...

JAXB Binding Exception

I got the folowing error while parsing the XSD to Java Object Exception in thread "main" java.lang.IllegalArgumentException: Expected class ja vax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation. AccessType Can any one give the solution for this error ...