0
soap webserviceからxml応答を取得していますが、アンマーシャルしているときにnull.whenがコンソールに出力されていますが、正しく出力されますが、unmarshallするとnullが出力されます。以下は SOAPMessageレスポンスを解析してnullを取得する
は私の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、結果)以下
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); }
応答
を取得した後、アンマーシャリングのためのコードです。はこの<?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>
が、私はアンマーシャリングと都市と組織の価値を印刷しようとしたとき、それはnullを出力しますのようなコンソールで応答を印刷しています。 お願いします。