【发布时间】:2014-09-05 15:48:30
【问题描述】:
我有两个应用程序,客户端应用程序(移动应用程序)具有 android 和服务器应用程序具有 Java 编程语言。 我已经使用 jaxb 来编组我的自定义列表。
Keyword objKeyword=new Keyword();
objKeyword.setKeywordList(keywordList); //keywordList=new ArrayList<Keyword>();
JAXBContext jc = JAXBContext.newInstance(Keyword.class);
Marshaller mar = jc.createMarshaller();
mar.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
sw = new StringWriter();
mar.marshal(objKeyword, sw);
我通过编写以下代码行在我的 android 应用程序中得到响应,
// Create request by specifying Namespace and Operation Name
SoapObject request = new SoapObject(WSDL_NAMESPACE, "getList");
// Creating envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
// Setting output SOAP object
envelope.setOutputSoapObject(request);
// Creating HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL);
// Invoking web service
androidHttpTransport.call(WSDL_NAMESPACE + "getList", envelope);
// Getting the response
SoapObject response = (SoapObject) envelope.bodyIn;
在我的回复中,我得到了以下格式的自定义列表,
<My_list>
<keyList>
<id>1</id>
<name>Key1</name>
</keyList>
<keyList>
<id>2</id>
<name>Key2</name>
</keyList>
</My_list>
现在,我想在我的 android 客户端应用程序中解组肥皂响应。 我读过JAXB不能与android一起使用,而是可以使用SAX解析器进行XML解析。
请帮忙。
【问题讨论】:
标签: android soap jaxb saxparser unmarshalling