jaxb

Generating Java Exceptions from XSD / binding Exceptions with JAXB2

For webservices we usually generate java beans with the maven-jaxb2-plugin and use JAXB2 marshalling in Spring. I am wondering how to handle (SOAP-)faults that are declared in the WSDL/XSD best. In the application I would like to use Java exceptions that are marshalled to the faults. Is this possible? I haven't found a way to generate ex...

Don't show Object Tag, only it's attribues with JAXB

If I have 3 objects A, B and C. Where A has B which has C, I don't want to show <a> <b> <c/> </b> </a> I want to show <a> <c/> </a> Is there any way to do it with JAXB? ...

How can I use JAXB from an unsigned applet (without signing it)?

I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can't change any of the security permission/policy files, or sign the application. I seem to get a Security exception, because JAXB is attempting to access fields or constructors that it can't in the applet sandbox. The browser is runnin...

Marshalling arraylist of abstract class in jaxb

I have a java application that i want to save the data in xml instead of a database. We decided to go with jaxb and instead of generating files based on the schema, we just added annotations to our java files. The issue we are running into is that we have an arraylist of an abstract class called Node. A Node has subclasses of either Modu...

web client for web service

Hello. I've a web-service that works fine when I access them from a J2SE (desktop) application. To access this service I do follow: generate stub classes by wsdl link using java wsimport tool then I create service using generated classes and run one of wsdl operations.It looks like this: MyWebServiceService webService = new MyWebServ...

JAXB generate java class from xsd

JAXB 1.5 installed under C:\Sun\jwsdp-1.5 J2SE 1.4.2 installed under C:\j2sdk1.4.2_08 copied sample.xsd file to C:\Sun\jwsdp-1.5\jaxb\bin went to C:\Sun\jwsdp-1.5\jaxb\bin and ran xjc.bat -p com.package sample.xsd got error message: Unrecognized option: -p Could not create the Java virtual machine. Please help me out...

JAXB Implementation class parameter return me null

My web services kept prompt me null input after I add in the implementation class. Below is my schema file. <xsd:complexType name="module"> <xsd:annotation> <xsd:appinfo> <jaxb:class name="Module" implClass="packageA.ModuleImpl"/> </xsd:appinfo> </xsd:annotation> <xsd:sequence> <xsd:e...

Marshalling an object that has object fields

Not sure if the title makes any sense. I have an object that I want to marshal using JAXB that looks like this: @XmlRootElement(name = "subscriptionRequest") public class RegistrationRequest { private Long id; private RegistrationSource registrationSource; } The RegistrationSource object: public class RegistrationSo...

Generating C# classes from XML schema that use JAXB (Java Architecture for XML Binding)

I have a number of XML schema that use JAXB (Java Architecture for XML Binding) markup, similar to the following: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="1.0"> <xs:element name="H"> <xs:annotation> <xs:appinfo> ...

Duplicate namespace declarations in JAXB generated XML

I am using JAXB to generate XML from Java objects, it's a realtime, quite high message rate application and works fine most of the time. However occassionally and without any obvious clues as to why, I am getting duplicate namespace declarations in the generated XML. eg: <UpdateRequest xmlns="http://xml.mycomp.com/ns/myservice" ...

Does JAXB use bytecode instrumentation?

Someone where i work noticed (in stacktrace) that when running the jvm with -javaagent:spring-instrumentation.jar my JAXB annotated classes have strange new methods in them which we didn't write: e.g. SomeJaxbAnnotatedClass$JaxbAccessorM_getFields_setFields_java_util_Set.get Does this mean that jaxb uses bytecode instrumentation when it...

@XmlElementRefs & @XmlElementRef annotatinos in Java

Can some please explain to me what do @XmlElementRefs and @XmlElementRef annotations mean in Java and what is their use.. EDIT: @skaffman okay, suppose I have one such collection @XmlElementRefs({ @XmlElementRef(name="ElementA", type=ClassA), @XmlElementRef(name="ElementB", type=ClassB) } ) List<Object> items; N...

Making JAXB generate an XML processing instruction

I am generating XML dynamically using JAXB. Now, I want to convert it to HTML using XSL. How can i include <?xml-stylesheet type="text/xsl" href=""> in the dynamically generated XML? ...

JAXB XJC code generation - "schemaLocation" missing in xml generated by Marshaller

Hello I Use XJC tool to generate Java classes for my XSD schema. When I use JAXB Marshaller to marshall classes into XML payloads, I'm missing "schemaLocation" parameter in the output XML, but I declare this parameter in xsd file. How to enforce "schemaLocation" parameter in the output XML? Below is the beggining of my xsd schema file ...

tell jaxb to not remove underscores

Hi.Is there a way to tell JAXB to not remove underscores when creating getter/setter names from XML Schema? Reason: this causes loss of information and it is harder to trip between XML and Java; e.g. in written communications where one participant might be confused about "different names". Example: NR_ROR should not become getNRROR but...

JAXB marshall a Collection to a XmlElement and a XmlAttribute in one step

I would like to marshall a Collection as nested attributes. Right now I have: @XmlElement(name="entry") public Collection<Integer> getSizes(){ ... } which returns: <entry>1</entry> <entry>2</entry> But I would like to get: <entry id="1"/> <entry id="2"/> Is this possible without new classes? ...

Get rid of JAXBElement in classes generated by wsimport called from ant

Hi, I have the following problem: I'm using the wsimport ant task to create a webservice client (for salesforce.com). Everything's working fine but the generated classes all use this strange JAXBElement class for all bean properties. Eg: public void setLastName(JAXBElement<String> value) { this.lastName = ((JAXBElement<String> ) ...

JAXB Customizations and List<Object>

Hi everybody. I used JAXB to create some classes from an XSD. The result was not quite what I expected and most probably it can be customized. It created a generic list instead of 3 different lists. Can this be corrected somehow? @XmlElements({ @XmlElement(name = "M1", type = M1_Type.class), @XmlElement(name = "M2", type = M2_...

Server-Side XML Validation with CXF Webservice

Hey guys, I'm working on 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 validation to enforce a number of constraints on the request. So, my question. How do I return ...

How can I customize serialization of a list of JAXB objects to JSON?

I'm using Jersey to create a REST web service for a server component. The JAXB-annotated object I want to serialize in a list looks like this: @XmlRootElement(name = "distribution") @XmlType(name = "tDistribution", propOrder = { "id", "name" }) public class XMLDistribution { private String id; private String name; // no...