jaxb2

JAXB2: Mapping nested elements into the same Java class

这一生的挚爱 提交于 2019-12-04 03:38:51
问题 I'm having trouble trying to map nested elements into the same Java class. XML What I'm trying to do here is to set id attribute and text element into SlideText class. <module name="test project"> <slide id="1"> <layout> <text>hello</text> </layout> </slide> </module> Module class @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Module { @XmlAttribute private String name; @XmlElements({ @XmlElement(name = "slide", type = SlideText.class) }) private Slide slide; } Slide class

How can I get JAXB2 to emit CamelCase bindings?

安稳与你 提交于 2019-12-04 03:22:55
问题 I'm generating Java classes from a WSDL using the jaxws-maven-plugin's wsimport goal. Out of the box, this generates hideous classes and methods from the XML schema; e.g., a class called MYOBJECT from an XML element named MY_OBJECT. I've found that I can customize my JAXB2 bindings with an external file; this would be acceptable for a small number of classes and methods, but the overhead of manually naming everything in this case is undesirable. Some searching uncovers references to an XJC

Programmatically use WsImport with JAXB plugins without Maven or ANT?

好久不见. 提交于 2019-12-04 02:59:23
问题 I am using WsImport to generate some Java sources from a remote WSDL file. Note that this is being from inside a regular Scala project i.e. it is not being done in a Maven or Ant build: import com.sun.tools.ws.WsImport def run(wsdlFile: File, destination: File, packageName: String = "generated"): Seq[File] = { sys.props("javax.xml.accessExternalDTD") = "all" sys.props("javax.xml.accessExternalSchema") = "all" val xjcArgs = "" //TODO val args = s"-Xnocompile -XadditionalHeaders $xjcArgs -J

jaxb2-maven-plugin only executing first execution

怎甘沉沦 提交于 2019-12-04 02:54:20
问题 I'm trying to convert multiple XSDs to POJOs in different packages using JAXB using the jaxb-maven plugin. I've set it up to use multiple execution blocks, the first execution block executes, then I get a message saying: No changes detected in schema or binding files This is an extract from my pom.xml: ... <build> <pluginManagement> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.5</version> </plugin> </pluginManagement> <plugins> <!-- JAXB

Netbeans with JAXB Random ClassCastException ..cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

扶醉桌前 提交于 2019-12-03 18:59:33
问题 I have downloaded the Soap messages from a SOAP Service and trying to mock the Soap service by returning the downloaded messages. the following code shows how I am Unmarshalling the Soap message into the required Response public static DataClientType unmarshallFile(String fileName) throws Exception { XMLInputFactory xif = XMLInputFactory.newFactory(); XMLStreamReader xsr = xif.createXMLStreamReader(ClientSampleSoapResponseData.class.getResourceAsStream(fileName)); xsr.nextTag(); // Advance to

namespace issue on web service with Apache CXF

て烟熏妆下的殇ゞ 提交于 2019-12-03 13:50:53
问题 I'm using Apache CXF 2.7.3, and running into a namespace issue that I really don't understand. I've tried extensively to search on this, but most of the results that I find are for different behaviors. The issue is when invoking the web service, it will fail if the parameter element is namespace qualified. All the rest of the elements in the message are qualified, and it accepts that, just not the parameter element. Here is the precise behavior: request WITHOUT parameter element qualified:

Specify a package instead of “classesToBeBound” for spring Jaxb2Marshaller

亡梦爱人 提交于 2019-12-03 10:56:35
I am trying to use Jaxb2Marshaller to marshal a set of java classes using spring. I know this can be done using the following code <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>com.example.test1</value> <value>com.example.test2</value> </list> </property> </bean> What I would like to do is instead of specifying a list of classes, I would like to specify just the package name containing all the classes ( in the above case com.example). Does anyone know of a way to do this, or any other way which does not require

What is the Jaxb equivalent of a Text node value?

女生的网名这么多〃 提交于 2019-12-03 10:34:00
I am looking to convert a class that looks like this ... public class Amenity { public String id; public String value; } into the following XML using JaxB annotations: <amenity id="id-string-here">value-string-here</amenity> Does anyone know what annotation to use on the value member variable to accomplish this? The closest I've gotten so far is: @XmlRootElement public class Amenity { @XmlAttribute public String id; @XmlElement public String value; } Unfortunately this approach doesn't allow me to specify that the value member variable should not be rendered as its own tag <value></value> .

Why does JAXB sometimes map to JAXBElement?

依然范特西╮ 提交于 2019-12-03 09:40:52
问题 There is a placeholder answer over at the unofficial guide with a link to an article which (to me) seems quite unrelated. I use XJC to generate my JAXB classes and while most of them map to each other as expected, some elements get mapped to JAXBElement<Foo> . This is most annoying for graphs with cycles, where sometimes the parent node of a Foo element will be the JAXBElement<Foo> , which doesn't itself have a parent property, breaking the cycle. I can think of various workarounds, but it

JAXB generated classes of certain types implementing a custom interface

南笙酒味 提交于 2019-12-03 08:42:34
I am working on an application that uses XJC to generate Java POJOs from XSDs. There are dozens of schemas, and that number will grow. The application also needs to be able to handle different versions of the same schema, which means that I will have multiple schemas defining common types. I am trying to customize the bindings so that certain core types implement a common interface. The Inheritance plugin of JAXB2 Basics seems to do what I need, but I can't seem to nail the right syntax. Here is the relevant part of my schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http:/