dbs
2024-12-23 73734f096b25cb3c350ddceec46e47f4de004b7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.itstyle.mdm.utils.model;
 
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
@JacksonXmlRootElement(localName = "soap:Envelope")
public class SoapEnvelopeProduct {
    @JacksonXmlProperty(localName = "Body")
    private SoapBody body;
 
    // getters and setters
    public SoapBody getBody() {
        return body;
    }
 
    public void setBody(SoapBody body) {
        this.body = body;
    }
 
    public static String getResJson(String xml){
        XmlMapper xmlMapper = new XmlMapper();
        SoapEnvelopeProduct envelope = null;
        String jsonStr="";
        try {
            envelope = xmlMapper.readValue(xml, SoapEnvelopeProduct.class);
            jsonStr = envelope.getBody().getReceiveTCGResponse().getReceiveTCGResult().trim();
        } catch (Exception e) {
            jsonStr="{\"error\":\""+e.getMessage()+"\"}";
        }
        return jsonStr;
    }
}
 
class SoapBody {
    @JacksonXmlProperty(localName = "ReceiveTCGResponse")
    @JacksonXmlElementWrapper(useWrapping = false)
    private ReceiveTCGResponse receiveTCGResponse;
 
    // getters and setters
    public ReceiveTCGResponse getReceiveTCGResponse() {
        return receiveTCGResponse;
    }
 
    public void setReceiveTCGResponse(ReceiveTCGResponse receiveTCGResponse) {
        this.receiveTCGResponse = receiveTCGResponse;
    }
}
 
@JacksonXmlRootElement(localName = "ReceiveTCGResponse", namespace = "http://www.hitachi.com/HITPHAMS")
class ReceiveTCGResponse {
    @JacksonXmlProperty(localName = "ReceiveTCGResult")
    private String receiveTCGResult;
 
    // getters and setters
    public String getReceiveTCGResult() {
        return receiveTCGResult;
    }
 
    public void setReceiveTCGResult(String receiveTCGResult) {
        this.receiveTCGResult = receiveTCGResult;
    }
}