Я получаю ответ xml от soap webservice, но когда я разоблачаю его, я получаю null.when я печатаю его на консоли, он печатает правильно, но когда я его отменю, он печатает null.Анализ с помощью ответа SOAPMessage получения null
Ниже приведен код для маршализации после получения ответа
private static void printSOAPResponse(SOAPMessage soapResponse)
{
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
System.out.print("\nResponse SOAP Message = ");
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
XMLInputFactory xif = XMLInputFactory.newFactory();
//StreamSource xml = new StreamSource(soapResponse.toString());
XMLStreamReader xsr = xif.createXMLStreamReader(sourceContent);
xsr.nextTag();
while(!xsr.getLocalName().equals("HelpDesk_Query_ServiceResponse")) {
xsr.nextTag();
}
JAXBContext jc = JAXBContext.newInstance(HelpDesk_Query_ServiceResponse.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<HelpDesk_Query_ServiceResponse> jb = unmarshaller.unmarshal(xsr, HelpDesk_Query_ServiceResponse.class);
xsr.close();
HelpDesk_Query_ServiceResponse response = jb.getValue();
System.out.println(response.City);
System.out.println(response.Organization);
}
Ниже моего Java POJO класс
@XmlAccessorType(XmlAccessType.FIELD)
public class HelpDesk_Query_ServiceResponse {
@XmlAttribute
String Assigned_Group;
@XmlAttribute
String Organization;
@XmlAttribute
String City;
//other attribute and their Getter and setter
}
Этой линии transformer.transform (sourceContent, результат); печатает отклик в консоли, как этот
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns0:HelpDesk_Query_ServiceResponse xmlns:ns0="urn:XXXX_HPD_IncidentInterface_WS__XXXXX" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Assigned_Group>TIM-CSDWINDOWS-ADMIN</ns0:Assigned_Group>
<ns0:Assigned_Group_Shift_Name/>
<ns0:City>HYDERABAD</ns0:City>
<ns0:Organization>XXX_TIM</ns0:Organization>
<ns0:Priority>Medium</ns0:Priority>
<ns0:Product_Model_Version/>
<ns0:Product_Name/>
<ns0:HPD_CI_ReconID/>
<ns0:z1D_CI_FormName/>
</ns0:HelpDesk_Query_ServiceResponse>
</soapenv:Body>
, но когда я маршализацию и пытается напечатать город и значение организации печатает нуль. , пожалуйста, помогите мне в этом.