I want to convert SOAP XML to Java Object without using xsd files and other stuff. I generate SOAP XML using POJO classes, #Xml annotations. What I want is to somehow deserialize String to not Envelope.class Object, but NumberToWords.class Object.
And by the way I didn't wanna have ns2:/xmlns="" stuff, that's why I used final static String as #XmlAttribute`s instead of namespace initializations.
Here are my classes >>>
#Setter
#Builder
#ToString
#NoArgsConstructor
#AllArgsConstructor
#XmlRootElement(name = "soap:Envelope")
public class Envelope {
#XmlAttribute(
name = "xmlns:soap"
)
#JacksonXmlProperty(isAttribute = true)
private static final String xmlns = "http://schemas.xmlsoap.org/soap/envelope/";
#XmlElement(
name = "soap:Body"
)
private Body body;
public String printBody() {
return body.toString();
}
}
#Getter
#Setter
#Builder
#NoArgsConstructor
#AllArgsConstructor
#XmlRootElement
#XmlAccessorType(XmlAccessType.FIELD)
#JsonInclude(JsonInclude.Include.NON_NULL)
public class Body {
#XmlElement(name = "NumberToWords")
private NumberToWords numberToWords;
#XmlElement(name = "Name")
private Name name;
}
#Getter
#Builder
#ToString
#NoArgsConstructor
#AllArgsConstructor
#XmlAccessorType(XmlAccessType.FIELD)
public class NumberToWords {
#XmlAttribute(name = "xmlns")
private final static String xmlns = "http://www.dataaccess.com/webservicesserver/";
#XmlElement(name = "ubiNum")
private Integer ubiNum;
}
Mapper Class which gets Marshaller Bean from another config class, but I decided to not add it here.
#Component
#RequiredArgsConstructor
public class EnvelopeMapper {
private final Marshaller marshaller;
#SneakyThrows
public String getXml(NumberToWords numberToWords) {
Envelope envelope = Envelope.builder()
.body(
Body.builder()
.numberToWords(numberToWords)
.build())
.build();
StringWriter stringWriter = new StringWriter();
marshaller.marshal(envelope, stringWriter);
return stringWriter.toString();
}
}
localhost:8080/get-num-xml/123
STRING:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
<ubiNum>123</ubiNum>
</NumberToWords>
</soap:Body>
</soap:Envelope>
When I call this endpoint it throws an exception.
#GetMapping("/get-num-xml/{num}")
public String getNumXml(#PathVariable Integer num) throws JAXBException {
String xml = envelopeService.getNumberToWords(num);
NumberToWords numberToWords = (NumberToWords) unmarshaller.unmarshal(new StringReader(xml));
System.out.println(numberToWords.getUbiNum());
return envelopeService.getNumberToWords(num);
}
GIVES:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Envelope"). Expected elements are <{}Name>,<{}body>,<{}soap:Envelope>
This one is also throws an exception.
#GetMapping("/get-num-xml/{num}")
public String getNumXml(#PathVariable Integer num) throws JAXBException, SOAPException, IOException {
String xml = envelopeService.getNumberToWords(num);
SOAPMessage message = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(xml.getBytes()));
JAXBContext jc = JAXBContext.newInstance(NumberToWords.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
NumberToWords rc = (NumberToWords) unmarshaller.unmarshal(message.getSOAPBody().extractContentAsDocument());
return envelopeService.getNumberToWords(num);
}
GIVES:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.dataaccess.com/webservicesserver/", local:"NumberToWords"). Expected elements are (none)
I don't have a clue how to unmarshal xml, so I hope someone has an answer for this one.
Related
TL;DR: When I unmarshall from XML to POJO I only have the XmlAttributes well mapped, however all XmlElement are null.
Hi there!
I have the following problem. This class was generated with JAXB
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"activity"
})
#XmlRootElement(name = "activityDetails", namespace = "http://lorem.ipsum.com/")
public class ActivityDetails {
#XmlElement(required = true)
protected Activity activity;
#XmlAttribute(name = "schemaVersion", required = true)
protected float schemaVersion;
#XmlAttribute(name = "actionType")
protected ActionTypes actionType;
#XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar timestamp;
This is an example XML
<activityDetails
actionType="CREATE"
schemaVersion="2.0"
timestamp="2020-01-02T15:31:50.549Z"
xmlns="http://lorem.ipsum.com/">
<activity>
<activityId>
<start>2020-01-01T03:00:00Z</start>
<end>2020-01-02T02:59:00Z</end>
</activityId>
</activity>
</activityDetails>
But, when this code is executed (please don't judge me, it's legacy code):
Object xmlClass = Class.forName("com.lorem.ipsum." + className).getConstructor().newInstance();
final JAXBContext jaxbContext = JAXBContext.newInstance(xmlClass.getClass());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Object object = unmarshaller.unmarshal(new StringReader(element));
The result "object" have all XmlAttribute well mapped, but no one of their XmlElement
PS: The namespace in the generated class was added manually, if I don't do that I have this exception:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://lorem.ipsum.com/", local:"activityDetails"). Expected elements are <{}activityDetails>
Thanks in advance.
UPDATED: If I set all #XmlElement the namespace property I finally map the elements, but I must intervene all the classes. Is there another way to achieve that without having to modify all the fields of all the classes?
I guess I am able to figure out the issue. This is happening because you have not provided any prefix to your namespace in XML. Following code would work for your provided sample XML:
XML:
<activityDetails
actionType="CREATE"
schemaVersion="2.0"
timestamp="2020-01-02T15:31:50.549Z"
xmlns:ns0="http://lorem.ipsum.com/">
<activity>
<activityId>
<start>2020-01-01T03:00:00Z</start>
<end>2020-01-02T02:59:00Z</end>
</activityId>
</activity>
</activityDetails>
ActivityDetails.class:
#XmlAccessorType(XmlAccessType.FIELD)
#Data
#XmlRootElement(name = "activityDetails", namespace = "http://lorem.ipsum.com/")
public class ActivityDetails {
private Activity activity;
#XmlAttribute
private float schemaVersion;
#XmlAttribute
private String actionType;
#XmlAttribute
private String timestamp;
}
Activity.class:
#Data
#XmlAccessorType(XmlAccessType.FIELD)
public class Activity {
private ActivityID activityId;
}
ActivityID.class:
#Data
#XmlAccessorType(XmlAccessType.FIELD)
public class ActivityID {
private String start;
private String end;
}
Main.class:
public class Main {
public static void main(String[] args) throws JAXBException, XMLStreamException {
final InputStream inputStream = Main.class.getClassLoader().getResourceAsStream("activity.xml");
final XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
final Unmarshaller unmarshaller = JAXBContext.newInstance(ActivityDetails.class).createUnmarshaller();
final ActivityDetails activityDetails = unmarshaller.unmarshal(xmlStreamReader, ActivityDetails.class).getValue();
System.out.println(activityDetails.toString());
Marshaller marshaller = JAXBContext.newInstance(ActivityDetails.class).createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(activityDetails, System.out);
}
}
Following is your output:
ActivityDetails(activity=Activity(activityId=ActivityID(start=2020-01-01T03:00:00Z, end=2020-01-02T02:59:00Z)), schemaVersion=2.0, actionType=CREATE, timestamp=2020-01-02T15:31:50.549Z)
<ns0:activityDetails xmlns:ns0="http://lorem.ipsum.com/" schemaVersion="2.0" actionType="CREATE" timestamp="2020-01-02T15:31:50.549Z">
<activity>
<activityId>
<start>2020-01-01T03:00:00Z</start>
<end>2020-01-02T02:59:00Z</end>
</activityId>
</activity>
</ns0:activityDetails>
Finally I found this solution: Instead of putting the namespace in each of the XMLElements I put the following package-info.java in the package of the generated classes.
#XmlSchema(
elementFormDefault=XmlNsForm.QUALIFIED,
namespace="http://lorem.ipsum.com/",
xmlns={#XmlNs(prefix="", namespaceURI="http://lorem.ipsum.com/")})
package com.lorem.ipsum.generated;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
I want to parse out different types based on xml, when header=1 then User, header=2 then Order etc. for example:
<entity>
<header>1</header>
<body>
<userId>1</userId>
<userName>jonh</userName>
...
<body>
</entity>
<entity>
<header>2</header>
<body>
<orderId>1</orderId>
<orderNo>20200101</orderNo>
...
<body>
</entity>
How to implement this function?
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Object object = unmarshaller.unmarshal(xml);
I would try this: provide the type when unmarshalling. So maybe do something like this: create a transient facade object:
public class XmlEntityFacade {
private int header;
private Object body;
//getters and setters...
}
And then cast this type while unmarshalling:
...
XmlEntityFacade facade = (XmlEntityFacade) unmarshaller.unmarshal(xml);
Then you can access the value of the by calling .getHeader() and body with .getBody() (getters that you have provided XmlEntityFacade class). And then depending on the value cast the required type to the Object.
public class TwiceUnmarshalTest {
#Data
#ToString
public static abstract class HeaderResponse {
private String header;
}
#XmlRootElement(name = "entity")
#XmlAccessorType(XmlAccessType.FIELD)
public static class XmlHeaderResponse extends HeaderResponse {
}
private final String xml = "<entity>" +
" <header>2</header>" +
" <body>" +
" <orderId>1</orderId>" +
" <orderNo>2020</orderNo>" +
" </body>" +
"</entity>";
#SuppressWarnings("unchecked")
public static <T> T unmarshal(Reader reader, Class<T> typeClass) throws Exception {
JAXBContext jaxbContext = JAXBContext.newInstance(typeClass);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
return (T) unmarshaller.unmarshal(reader);
}
#Test
public void headerResponse() throws Exception {
HeaderResponse response = unmarshal(new StringReader(xml), XmlHeaderResponse.class);
System.out.println(response);
}
#ToString(callSuper = true)
public static abstract class Response<T> extends HeaderResponse {
#XmlAnyElement(lax = true)
public T body;
}
#Data
#XmlRootElement(name = "body")
public static class Order {
private String orderId;
private String orderNo;
}
#XmlRootElement(name = "entity")
#XmlSeeAlso({Order.class})
public static class OrderResponse extends Response<Order> {
}
#Test
public void response() throws Exception {
XmlHeaderResponse response = unmarshal(new StringReader(xml), XmlHeaderResponse.class);
System.out.println(response);
//TwiceUnmarshalTest.HeaderResponse(header=2)
if (response.getHeader().equals("2")) {
OrderResponse orderResponse = unmarshal(new StringReader(xml), OrderResponse.class);
System.out.println(orderResponse);
//TwiceUnmarshalTest.Response(super=TwiceUnmarshalTest.HeaderResponse(header=2), body=TwiceUnmarshalTest.Order(orderId=1, orderNo=2020))
}
}
}
unmarshal twice, just get the header first, then get the entity. Not very good but can be used.
I'm getting null value when unmarshelling the xml file to java class. But the xml file as values corresponding to the its attributes. Is there any mistake in my pojo class or unmarshelling?
Please help
This is my pojo
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "")
#XmlRootElement(name = "CardUpdateResponse",namespace="http://www.samople.com/Prepaid")
public class FVCardUpdateResponse {
#XmlElement(name = "AccountNumber")
private String AccountNumber;
#XmlElement(name = "ResCode")
private String ResCode;
#XmlElement(name = "ResErrorCode")
private String ResErrorCode;
#XmlElement(name = "ResErrorMsg")
private String ResErrorMsg;
//Setters and Getters
}
This is my xml file
<?xml version="1.0" encoding="UTF-8"?>
<CardUpdateResponse xmlns="http://www.samople.com/Prepaid">
<CARDUPDATE_RET>
<ResErrorMsg>ID Issue Date must be equal or less than present date</ResErrorMsg>
<ResErrorCode>ErrIsud01</ResErrorCode>
<ResCode>0</ResCode>
<ACCOUNTNUMBER>2000000003918246</ACCOUNTNUMBER>
</CARDUPDATE_RET>
</CardUpdateResponse>
this is code for unmarshelling
public class XmlUnmarshelling {
public void unmarshell()
{
try
{
System.out.println("xml unmarshelling class");
File file = new File("D:/var/lib/tomcat7/webapps/tmpFiles/1.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(FVCardUpdateResponse.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
FVCardUpdateResponse CARDUPDATE_ret = (FVCardUpdateResponse) jaxbUnmarshaller.unmarshal(file);
System.out.println("xml unmarshelled = "+CARDUPDATE_ret.getResErrorMsg());//Getting null value as response.
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Your POJO doesn't have the same structure as your XML. CardUpdateResponse doesn't directly contain the properties in your POJO, it contains CARDUPDATE_RET element which contains the properties.
You could modify your POJO like this to match the XML:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlRootElement(name = "CardUpdateResponse", namespace="http://www.samople.com/Prepaid")
public static class CardUpdateResponseWrapper {
#XmlElement(name="CARDUPDATE_RET")
private FVCardUpdateResponse response;
// Getter and setter for response
public static class FVCardUpdateResponse {
#XmlElement(name = "AccountNumber")
private String AccountNumber;
#XmlElement(name = "ResCode")
private String ResCode;
#XmlElement(name = "ResErrorCode")
private String ResErrorCode;
#XmlElement(name = "ResErrorMsg")
private String ResErrorMsg;
// Getters and setters
}
}
Now the CardUpdateResponseWrapper class will represent your root XML element and it will have instance of FVCardUpdateResponse which will represent the CARDUPDATE_RET XML element.
Do unmarshall it, just call:
File file = new File("D:/var/lib/tomcat7/webapps/tmpFiles/1.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(CardUpdateResponseWrapper.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
CardUpdateResponseWrapper wrapper = (CardUpdateResponseWrapper) jaxbUnmarshaller.unmarshal(file);
System.out.println(wrapper.getResponse().getResErrorMsg());
I think that the issue is a combination of two problems, one what Bohuslav is saying, the other you need to repeat your namespace on every XmlElement annotation, e.g.
#XmlElement(name = "ResCode", namespace="http://www.samople.com/Prepaid")
and one particular issue, you need to match the cases as well so the name for AccountNumber should be capitalized ACCOUNTNUMBER
We want to implement a RESTful-Webservice with JAX-RS and JAXB. We have a PUT method that consumes xml, that looks like the following:
<mailAccount>
<id>-1</id>
<name>test</name>
<mailaddress>test#gmx.de</mailaddress>
<password>1234</password>
<servertype>IMAP</servertype>
<host>hallo</host>
<port>5678</port>
<encryption>SSL/TLS</encryption>
<authentication>true</authentication>
<interval>12</interval>
</mailAccount>
We also have a MailAccount.class that is mapped to the xml.
#XmlRootElement
public class MailAccount {
private String name;
private String mailaddress;
private String password;
private String servertype;
private String host;
private int port;
private String encryption;
private boolean authentication;
private int interval;
private int id;
getter + setter...
}
The PUT-Method looks like the following:
#PUT()
#Path("/addMailAccount")
#Consumes(MediaType.APPLICATION_XML)
#Produces(MediaType.TEXT_HTML)
public Response addMailAccount(JAXBElement<MailAccount> mail) throws Exception{
MailAccount mailAccounts = mail.getValue();
StringWriter sw = new StringWriter();
JAXBContext jaxbContext = JAXBContext.newInstance(MailAccount.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(mailAccounts, sw);
String xmlConsume = sw.toString();
Source source = new StreamSource(new StringReader(xmlConsume));
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(MailAccountService.class.getResource("/emailAddresses.xsd"));
Validator validator = schema.newValidator();
//validator.validate(source);
return Response.status(200).entity(xmlConsume +"..."+ mailAccounts.getMailadress()).build();
}
Our goal is to marshalling the JAXB-Element to validate it against an XML-Schema. But the problem is the marshalling: First of all the elements are not in the correct order. The use of the propOrder Tag results every time in an internal server error.
The second problem is that the element "mailaddress" is empty. It is not marshalling and when i put it into the Response of this method, the value is null.
Here is what the PUT-Method is returning:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mailAccount>
<authentication>true</authentication>
<encryption>SSL/TLS</encryption>
<host>hallo</host>
<id>-1</id>
<interval>12</interval>
<name>test</name>
<password>1234</password>
<port>5678</port>
<servertype>IMAP</servertype>
</mailAccount>
...null
Here are a couple items that should help:
propOrder
Below is an example of applying a propOrder to your class. It is important to remember that you need to include all mapped fields/properties that are mapped to XML elements in the propOrder.
import javax.xml.bind.annotation.*;
#XmlRootElement
#XmlType(propOrder={"id", "name", "mailaddress", "password", "servertype", "host", "port", "encryption", "authentication", "interval"})
#XmlAccessorType(XmlAccessType.FIELD)
public class MailAccount {
private String name;
private String mailaddress;
private String password;
private String servertype;
private String host;
private int port;
private String encryption;
private boolean authentication;
private int interval;
private int id;
}
Doing Schema Validation as Part of the Marshal Operation
Below is a standalone example that demonstrates how you can leverage schema validation as part of the marshal operation instead of doing it as a separate operation (see: http://blog.bdoughan.com/2010/12/jaxb-and-marshalunmarshal-schema.html).
import java.io.File;
import javax.xml.XMLConstants;
import javax.xml.bind.*;
import javax.xml.validation.*;
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(MailAccount.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
File xml = new File("src/forum20699078/input.xml");
MailAccount mailAccount = (MailAccount) unmarshaller.unmarshal(xml);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(MailAccountService.class.getResource("/emailAddresses.xsd"));
marshaller.setSchema(schema);
marshaller.marshal(mailAccount, System.out);
}
}
For all those, who have to implement the XML validation with JAX-RS webservice, this is my PUT-Method after the hints from above. It works now fine for me.
#PUT()
#Path("/addMailAccount")
#Consumes(MediaType.APPLICATION_XML)
#Produces(MediaType.TEXT_HTML)
public Response addMailAccount(JAXBElement<MailAccount> mail) throws MailAccountServiceException{
String xmlConsume = "";
try{
MailAccount mailAccounts = mail.getValue();
StringWriter sw = new StringWriter();
JAXBContext jaxbContext = JAXBContext.newInstance(MailAccount.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(MailAccountService.class.getResource("/mailAccount.xsd"));
jaxbMarshaller.setSchema(schema);
jaxbMarshaller.marshal(mailAccounts, sw);
xmlConsume = sw.toString();
}
catch(Exception e){
throw new MailAccountServiceException("Fehlerhafte Anfrage: " + e.getCause().getMessage());
}
return Response.status(200).entity(xmlConsume).build();
}
i need your help : please, please please.
I've a Xades-signed XML document that i receive as a byteArray : so i convert my byteArray to a String.
After, i try to unmarhall so that i obtain a Java Object mapped.
The result is that i get an instance of "MyJavaObj" with all informations but Xades-Signature. My signature is null in the Java Object while all other informations are well-mapped. The following is my java method. Please, help me to get the object signature in the instance of MyJavaObj.
<school>
<documentVersion>2.10</documentVersion>
<teacher>
.....
</teacher>
<student>
<name></name>
<age></age>
....
</student>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-2b72d2f4-4794-4a8b-8cbf-4c74d33629a7">
<ds:SignedInfo>
........
</ds:SignedInfo>
.......
</ds:Signature>
</school>
this is the method to convert
public static MyJavaObj unmarshallBinary(final byte[] pByteStr) {
try {
final String xmlFlow = new String(pByteStr, "UTF-8");
final StringBuffer xmlStr = new StringBuffer(xmlFlow);
// Unmarshalling with JAXB
final JAXBContext jaxbContext = JAXBContext.newInstance("generated.package");
// marshaller
final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
// Unmarshalling
final JAXBElement<MyJavaObj> root = unmarshaller.unmarshal(
new StreamSource(new StringReader(xmlStr.toString())), MyJavaObj.class);
return root.getValue();
} catch (final Throwable excep) {
excep.printStacktrace();
}
}
MyJavaObj result = unmarshallBinary(..a ByteArray..);
result.getDocumentVersion() : returns 2.10;
result.getStudent() : returns the students;
result.getSignature() : return NULL;
The file MyJavaObj.java is well annotated
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "My_Java_Obj", namespace = "urn:my_java_obj",
propOrder = {"documentVersion", "teacher", "student","signature"})
public class MyJavaObj {
#XmlElement(name = "documentVersion", required = true)
protected String documentVersion;
#XmlElement(name = "teacher", required = true)
protected Teacher teacher;
#XmlElement(name = "student", required = true)
protected Student student;
#XmlElement(name = "Signature")
protected Signature signature;
#XmlAttribute(name = "Id", required = true)
#XmlJavaTypeAdapter(CollapsedStringAdapter.class)
#XmlID
#XmlSchemaType(name = "ID")
protected String id;
.....
getters and setters
}
Thanks for any help.
The Signature element is in the http://www.w3.org/2000/09/xmldsig#" namespace so you need to include this in the #XmlElement for the signature field.
#XmlElement(name="Signature", namespace="http://www.w3.org/2000/09/xmldsig#")
protected Signature signature;
For More Information
http://blog.bdoughan.com/2010/08/jaxb-namespaces.html
my solution is bit different
i used uddi-ws. Maven dependency is here:
<!-- https://mvnrepository.com/artifact/org.apache.juddi/uddi-ws -->
<dependency>
<groupId>org.apache.juddi</groupId>
<artifactId>uddi-ws</artifactId>
<version>3.3.2</version>
</dependency>
In class:
//in my case, import org.w3.x2000.x09.xmldsig.SignatureType isn't working
import org.w3._2000._09.xmldsig_.SignatureType;
//Signature declaration
private SignatureType Signature;
//namespace is important part, without namespace, it returns null
#XmlElement(name = "Signature", namespace = "http://www.w3.org/2000/09/xmldsig#")
public SignatureType getSignature() {
return Signature;
}
More info:
https://www.codesynthesis.com/pipermail/xsd-users/2006-December/000674.html