我不太清楚你的问题。如果我说错了。你想在第二个视图中创建一个“微调器更新方法”,它解析 xml 以获取肥皂请求,然后发送肥皂请求并拆分响应?
如果是,我建议您创建一个单独的类,您将在其中解析 xml 并发出请求。像这样的东西:
public class SomeRequest {
private static String xml = null;
private static String response= null;
public static void SomeRequest (String url, String sT, int protocoll, String[] Vars) {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
xml = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:mob='YOUR/URL' xmlns:arr='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>" +
"<soapenv:Header/>" +
"<soapenv:Body>" +
"<mob:Request>" +
"<!--Optional:-->" +
"<mob:Vars>" +
"<!--Zero or more repetitions:-->" +
"<arr:string>"+ Vars +"</arr:string>" +
"</mob:Vars>" +
"<!--Optional:-->" +
"<mob:protocoll>"+ protocoll +"</mob:protocoll>" +
"<!--Optional:-->" +
"<mob:session>"+ sT +"</mob:session>" +
"</mob:Request>" +
"</soapenv:Body>" +
"</soapenv:Envelope>";
try {
StringEntity se = new StringEntity(xml, HTTP.UTF_8);
se.setContentType("text/xml");
httpPost.addHeader("SOAPAction", "YOUR/REQUEST/URL");
httpPost.setEntity(se);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity resEntity = httpResponse.getEntity();
response= EntityUtils.toString(resEntity);
} catch (Exception e) {
System.out.println(e.toString());
Log.e("httpRequestException", e.toString());
}
}
}