jaxb

Avoid Empty Sub-Tags in XML if everything is blank in an object

落花浮王杯 提交于 2020-01-06 20:06:30
问题 We have JAXB objects marshing/unmarshalling XML. Currently, we get this tag, even though everything inside it is empty. We need to completely get rid of the Top section if all its sub-elements are empty. (If at least one is not empty, it should exist.) <ns2:Top> <ns2:OrganizationName></ns2:OrganizationName> <ns2:Address> <ns2:Street1></ns2:Street1> <ns2:Street2></ns2:Street2> <ns2:City></ns2:City> <ns2:ZipPostalCode></ns2:ZipPostalCode> </ns2:Address> </ns2:Top> The JAXB class is defined as:

Java JAXB xml pojo classes

和自甴很熟 提交于 2020-01-06 19:49:39
问题 How can I create the POJO classes with JAXB with such a xml structure : <principale> <procedure> <procedure> <param1>value1</param1> <param2>value2</param2> </procedure> <procedure> <param1>value3</param1> <param2>value4</param2> </procedure> </procedure> </principale> As you can see the first procedure tag is not the root one and is the same than the second procedure tag. 回答1: If the outer procedure element is not repeatable, try it with @XmlElementWrapper: @XmlRootElement(name="principale")

Sending/receiving objects over network in java

情到浓时终转凉″ 提交于 2020-01-06 19:30:55
问题 I am implementing new client server app. I would like to ask, What is the best way to send and receive objects via network? On server side , I have something like this but I am getting null pointer exception: @RequestMapping(value = "/test") @ResponseBody public Student myAction(){ Student student = new Student(1,"Miso"); return student; } On client side: public Student test(){ String prodGroup = ""; Student obj = null; try { url = new URL("http://localhost:8080/getData/test"); urlConn =

Add schema location to JAXB unmarshaller

ぃ、小莉子 提交于 2020-01-06 16:21:47
问题 I am facing the below error when JABX unmarshaller tries to unmarshall the xml Exception in thread "main" javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 456; The prefix "xsi" for attribute "xsi:nil" associated with an element type "customerProductStatus" is not bound.] When I looked at the xml being returned from the server , it is the below : <customerProductStatus xsi:nil = "true"></customerProductStatus> I don't see

wsdl with conflicting xsd imports

↘锁芯ラ 提交于 2020-01-06 15:29:33
问题 I tried to find a solution for some time to the following problem. I have a wsdl file containing several (6) xsd imports. I cannot change these xsd's because they are external to my project. There are 4 definitions all together which are slightly defined different in 2 of these schemas. I was attempting to translate each 'conflicting' xsd schema to it's own package. I tried following bindings, but it did not do the job: testbindings.jaxb: <bindings xmlns="http://java.sun.com/xml/ns/jaxb"

JaxB inheritance marshalling abstract classes

时光毁灭记忆、已成空白 提交于 2020-01-06 15:20:08
问题 I've been searching for the best way to perform the following action using JaxB but I cannot find a way that works. I followed the tutorial here to allow for marshaling and unmarshaling of subclasses. It achieves all that I am looking for, except that in order for the subclasses to be properly marshaled and unmarshaled, they must be wrapped in a class with a specific @XmlRootElement . This doesn't allow you to represent the classes themselves as Xml on their own. I want to have a classes like

JAXB add additional static root element

…衆ロ難τιáo~ 提交于 2020-01-06 09:36:26
问题 I have the following POJO: @XmlRootElement(name="SessionStartInput") public class SessionStartInput { @XmlElement(name = "Header", required = true, nillable = true) protected SessionStartInputHeader header; @XmlElement(name = "Parameters", required = true, nillable = true) protected SessionStartInputParameters parameters; ... } Which generates: <SessionStartInput> <Header></Header> <Parameters></Parameters> </SessionStartInput> I want to generate: <SessionStartInput> <Input> <Header></Header>

JAXB marshal to string works differently on different computers

情到浓时终转凉″ 提交于 2020-01-06 05:26:35
问题 I have this test java app: @XmlRootElement public class Car { @XmlElement(namespace="http://www.example.com/CAR_NAME") private String name; @XmlElement(namespace="http://www.example.com/CAR_PRICE") private int price; @XmlElement(namespace="http://www.example.com/CAR_BUS") private Bus bus; //constructors, getters and setters @XmlRootElement public class Bus { @XmlElement(namespace="http://www.example.com/BUS_NAME") private String name; @XmlElement(namespace="http://www.example.com/BUS_PRICE")

JAXB marshal to string works differently on different computers

↘锁芯ラ 提交于 2020-01-06 05:26:04
问题 I have this test java app: @XmlRootElement public class Car { @XmlElement(namespace="http://www.example.com/CAR_NAME") private String name; @XmlElement(namespace="http://www.example.com/CAR_PRICE") private int price; @XmlElement(namespace="http://www.example.com/CAR_BUS") private Bus bus; //constructors, getters and setters @XmlRootElement public class Bus { @XmlElement(namespace="http://www.example.com/BUS_NAME") private String name; @XmlElement(namespace="http://www.example.com/BUS_PRICE")

Jaxb in websphere

拈花ヽ惹草 提交于 2020-01-06 04:14:27
问题 Hi I have developed the web application to marshall and unmarshall using JAXB. The web application is working in tomcat without any issues. But when I tried in Websphere 7.0.0.13 its returning null object.Please help me on this issue. 回答1: I had the same problem. Under this link is solution that help me. What i did: 1. In the administrative console, click Applications > Application Types > WebSphere enterprise applications > app-name > Class loading and update detection. 2. Under Class