StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
<?xml version="1.0" encoding="utf-8"?>rn" + "<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">rn" + " <soap:Body>rn" + " <SendOTTResponse xmlns="http://tempuri.org/">rn" + " <SendOTTResult>rn" + " <ResCode>0</ResCode>rn" + " <ResDesc>Sent</ResDesc>rn" + " </SendOTTResult>rn" + " </SendOTTResponse>rn" + " </soap:Body>rn" + "</soap:Envelope>" + "</soap:Envelope>
public class SendOTTResult { public int ResCode; public String ResDesc; } public class SendOTTResponse { public SendOTTResult SendOTTResult; }
package com.example.stackoverflow; import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import lombok.Data; public class JAXBExample { public static void main(String[] args) throws Exception { String xml = <span>"<?xml version=<span>"</span>1.0<span>"</span> encoding=<span>"</span>utf-8<span>"</span>?><span>n</span>"</span> + <span>"<soap:Envelope xmlns:soap=<span>"</span>http://www.w3.org/2003/05/soap-envelope<span>"</span> xmlns:xsi=<span>"</span>http://www.w3.org/2001/XMLSchema-instance<span>"</span> xmlns:xsd=<span>"</span>http://www.w3.org/2001/XMLSchema<span>"</span>><span>n</span>"</span> + <span>" <soap:Body><span>n</span>"</span> + <span>" <SendOTTResponse xmlns=<span>"</span>http://tempuri.org/<span>"</span>><span>n</span>"</span> + <span>" <SendOTTResult><span>n</span>"</span> + <span>" <ResCode>0</ResCode><span>n</span>"</span> + <span>" <ResDesc>Sent</ResDesc><span>n</span>"</span> + <span>" </SendOTTResult><span>n</span>"</span> + <span>" </SendOTTResponse><span>n</span>"</span> + <span>" </soap:Body><span>n</span>"</span> + <span>"</soap:Envelope>"</span>; JAXBContext jaxbContext = JAXBContext.newInstance( Envelope.class, Body.class, SendOTTResponse.class, SendOTTResult.class ); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); System.out.println(unmarshaller.unmarshal(new StringReader(xml))); } @Data public static class SendOTTResult { @XmlElement(name = "ResCode", namespace="http://tempuri.org/") public int ResCode; @XmlElement(name = "ResDesc", namespace="http://tempuri.org/") public String ResDesc; } @Data public static class SendOTTResponse { @XmlElement(name = "SendOTTResult", namespace="http://tempuri.org/") public SendOTTResult SendOTTResult; } @Data public static class Body { @XmlElement(name = "SendOTTResponse", namespace="http://tempuri.org/") public SendOTTResponse SendOTTResponse; } @Data @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name="Envelope", namespace="http://www.w3.org/2003/05/soap-envelope") public static class Envelope { @XmlElement(name = "Body", namespace="http://www.w3.org/2003/05/soap-envelope") public Body Body; } }
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Your account is signed in on the device(s) below. Sign out of at least one of them to continue signing in on this device.
Your account is signed in on the device(s) below. Sign out directly on one of those devices, or wait until the sign-in again time shown below.
If you cant access those devices, please contact the administrator to sign them out for you.
Input your email to receive reset password link, or if you remember your password, you can click