Mam poniższy kod aplikacji na Androida poniżej. Próbuję połączyć się z usługą internetową za pośrednictwem protokołu HTTP. Usługa internetowa wykorzystuje oś apache. Jednak pojawia się błąd "Error reading XMLStreamReader" w odpowiedzi. Naprawdę utknąłem i nie jestem pewien, co mogę zrobić. Czy to możliwe, że istnieją różne wersje klienta HTTP i SOAP używane po stronie serwera i klienta? Każda pomoc w tym zakresie byłaby bardzo doceniana. Usługa internetowa jest bardzo prosta metoda sayHello wyświetla argument podany w arg0 = some_stringBłąd odpowiedzi koperty SOAP: błąd odczytu pliku XMLStreamReader
public class MainActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
BufferedReader in = null;
try {
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(
"http://10.0.0.63:8080/archibus/cxf/HelloWorld/sayHello");
request.addHeader("Content-Type", "text/xml");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("arg0", "testing"));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
request.setEntity(formEntity);
HttpResponse response = client.execute(request);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String page = sb.toString();
// Log.i(tag, page);
System.out.println(page);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
http://www.lalit3686.blogspot.in/2012/06/calling-soap-webservice-using- httppost.html –