jaxb

Generate the xml code specified from java file using JAXB

Hi, Can anybody please help me by providing the java code using JAXB to create an xml file covering the code below: <possibleValues> <possibleValue representsNull="false" cannotBeSoleTarget="false"> <displayName>True</displayName> <value>True</value> </possibleValue> <possibleValue representsNull="false" can...

JAXB Collections (List<T>) Use Pascal Case instead of Camel Case for Element Names

Hi All, I have a number of JAXB beans that are directly marshalled and unmarshalled using Jersey. E.g. @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Artifact", propOrder = { "artifactId", "artifactType", "contentHash" }) @XmlSeeAlso({ EmailArtifact.class, ManagedDocArtifact.class }) @XmlRootElement(name ="...

Is there something like PostConstruct for JAXB-annnotated classes?

I need to perform certain operations on a class after it was unmarshalled (after it is constructed by JAXB, rather then by myself). Is there such a functionality in JAXB? If not, how could I achieve it? ...

expose JAXB generated Class as WSDL web service

I have a bunch of very simple functions. Each function has one input and one output. OutputType function func(InputType); The types of input/output are defined in xsd schema and generated into java classes with JAXB/XJC. Now I want to expose those functions as WSDL Web service running on Geronimo. I just took a look at Axis/WSDL2J...

Jaxb Support for Netbeans 6.5

I have not been working on java for a long time, and now I am back; so I am sort of noob, particularly with Netbeans. I am using Netbeans 6.5 on Ubuntu. I want to use the Jaxb support to generate Jaxb binding from an XML schema, as documented at http://wiki.netbeans.org/NB6JAXBSample1 . But the document asks to click on "On Project node,...

How to validate against schema in JAXB 2.0 without marshalling?

I need to validate my JAXB objects before marshalling to an XML file. Prior to JAXB 2.0, one could use a javax.xml.bind.Validator. But that has been deprecated so I'm trying to figure out the proper way of doing this. I'm familiar with validating at marshall time but in my case I just want to know if its valid. I suppose I could mars...

JAXB to unmarshall <string>foobar</string>

Greetings! I have a server returning XML content to my client that looks like this: <string xmlns="...">foobar</string> I'm new to JAXB and have gotten a lot of stuff working, except this. I thought it would be pretty easy to marshal and unmarshal this to and from a String. It took a while, but I finally figured out how to marshal thi...

What do I need to do to accept an array parameter in webservice?

Hi I am use JAX-WS to make a web service. As parameters I am taking in two strings and an array of a objects whose type are a class in my project. I have the webservice interface and implementation created and it is similar to this: @WebMethod(operationName = "getStuff") @WebResult(name = "result") Mix getStuff( @WebParam(name =...

Using JAXB to unmarshal/marshal a List<String>

I'm trying to create a very simple REST server. I just have a test method that will return a List of Strings. Here's the code: @GET @Path("/test2") public List test2(){ List list=new Vector(); list.add("a"); list.add("b"); return list; } It gives the following error: SEVERE: A message body writer for Java type, ...

Critique my JAXB object wrapper.

Hello Ladies and Gents, I have a question on wrapping a jaxb created class and would really like to hear your inputs. My xsd looks a bit like: <ComplexService> <ComplexObject1> <Element1></Element1> <Parameter></Parameter> </ComplexObject1> <ComplexObject2> <Element2> </Element2> <Parameter> ...

Error using jaxb external bindings customization

I use the wsdlc tool (weblogic 10.3.1) to generate classes from wsdl. I have the following external jaxb bindings customization file: <jaxb:bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...

wsimport multiple generated wsdl's

I am using jbossws (with jax-ws) to serve 3 webservices generated from annotated POJOs. These 3 webservices share a few data classes and also have a common method (ping). They all reside in the same java package (namespace) The 3 WSDL files are generated automatically by jbossws at deploy time. Now I want to generate client code using ...

Reuse JAXB generated class as JAX-WS web service parameter

I have some XML type in Java classes which are defined in XSD and generated by XJC. Then I write some java methods with JAX-WS Annotation, and let those generated Java classes of XML type as parameter types of the web services. The code is deployed on Geronimo. And Geronimo should run some WsGen tasks to generate WSDL and service runti...

Parsing invalid xml

I parse xml using jaxb. I want to parse xml successfully also when xml is not valid that have additional tag. Just ignore tag that non-exist in xsd. Is it possible? ...

REST + json + JAXB + namespaces

I have been trying to wrap my head around POSTing json to a REST service and JAXB namespaces. I am using Resteasy to mark up the server side method. I have the following service: @POST @Mapped(namespaceMap={@XmlNsMap(namespace="http://acme.com", jsonName="")) @Path("/search") @Consumes("application/json") public List<I> search(SearchC...

EJB3 Web Services Error with JAXB

Update: I checked the JBoss log and found the following errors: 2009-10-28 10:21:34,472 ERROR [org.jboss.ws.metadata.wsdl.xmlschema.JBossXSErrorHandler] (main) JBossWS_ejb.uhandler.pds.hsc.xyzis.com_8603663089732759450.xsd[domain:http://www.w3.org/TR/xml-schema-1]::[key=src-resolve]::Message=src-resolve: Cannot resolve the name 'ns1:Mes...

jaxb unmarshal abusable by crafted xml when using default sax parser?

So in my current project I use the JAXB RI with the default Java parser from Sun's JRE (which I believe is Xerces) to unmarshal arbitrary XML. First I use XJC to compile an XSD of the following form: <?xml version="1.0" encoding="utf-8" ?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://...

How to make generated classes contain Javadoc from XML Schema documentation

I'm currently working with an XML Schema that has <xsd:annotation>/<xsd:documentation> on most types and elements. When I generate Java Beans from this XML Schema, then the Javadoc of those Beans only contains some generic generated information about the allowed content of the type/element. I'd like to see the content of the <xsd:docume...

How to marshal a DataHandler annotated as @XmlAttachmentRef with JAXB?

I'm trying to marshal an object which has a DataHandler field with JAXB (2.1.12). For streaming support, the DataHandler is annotated with @XmlAttachmentRef. Serialization and streaming over web services (Metro on JBoss) work fine, but plain marshalling with JAXB doesn't. Here is a stripped down example: public class DataHandlerAttachm...

JAXB appending unneeded namespace declarations to tags

I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:i...