在Android中使用不带ksoap2的SOAP Web服务
在我的Android应用程序中,我使用ksoap2库来使用soap(&.net)Web服务。它工作正常,但速度非常慢(用于解析、控件、循环和Base64ToBinary进程)。我想更快地解析它。不使用ksoap2就可以解析它吗?有什么想法吗?在Android中使用不带ksoap2的SOAP Web服务,android,xml,parsing,soap,ksoap2,Android,Xml,Parsing,Soap,Ksoap2,在我的Android应用程序中,我使用ksoap2库来使用soap(&.net)Web服务。它工作正常,但速度非常慢(用于解析、控件、循环和Base64ToBinary进程)。我想更快地解析它。不使用ksoap2就可以解析它吗?有什么想法吗? 谢谢你的推荐。慢是什么意思?它执行http请求,然后解析响应。您必须在异步任务中执行此操作。内存使用将取决于您得到的响应。也许你要求的太多了。查看关于如何调试的wiki 你说慢是什么意思?它执行http请求,然后解析响应。您必须在异步任务中执行此操作。内存
谢谢你的推荐。慢是什么意思?它执行http请求,然后解析响应。您必须在异步任务中执行此操作。内存使用将取决于您得到的响应。也许你要求的太多了。查看关于如何调试的wiki 你说慢是什么意思?它执行http请求,然后解析响应。您必须在异步任务中执行此操作。内存使用将取决于您得到的响应。也许你要求的太多了。查看关于如何调试的wiki KSoap2还有一个问题。不幸的是,ksoap2库不能与我的Web服务一起使用。最后,我完成了缺省http post 我希望这将有助于在未来的人
private String makeHttpRequest(){
try{
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://tempuri.org/\">"
+"<SOAP-ENV:Body>"
+ "<ns1:Connect>"
+ "<ns1:lstr_Login>xxxxx</ns1:lstr_Login>"
+"</ns1:Connect>"
+"</SOAP-ENV:Body>"
+"</SOAP-ENV:Envelope>";
String soapAction = "http://tempuri.org/Connect"; //this would be your soapAction from wsdl
StringEntity se = new StringEntity(request, HTTP.UTF_8);
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(new URI("http://xxxxxxxx.com/Storefront.asmx"));
httpPost.addHeader("Content-Type", "text/xml; charset=utf-8");
httpPost.addHeader("SOAPAction", soapAction);
httpPost.setEntity(se);
HttpResponse response = client.execute(httpPost);
int responseStatusCode = response.getStatusLine().getStatusCode();
Log.d(TAG, "HTTP Status code:"+responseStatusCode);
if(responseStatusCode>=200 && responseStatusCode<300){
//we got the success response from server. Now retrieve the value and go for usage.
String responseStr = EntityUtils.toString(response.getEntity());
//use this responseStr to parse with pullparsers or any
Log.d("Response", "Response:: "+ responseStr);
return responseStr;
}
}catch(Exception e){
//Write the proper catch blocks for exceptions
Log.e("Response Exception" , e.getMessage()+"",e);
}
return null;
}
私有字符串makeHttpRequest(){
试一试{
String request=“”
+""
+ ""
+“xxxxx”
+""
+""
+"";
字符串soapAction=”http://tempuri.org/Connect“;//这将是wsdl中的soapAction
StringEntity se=新的StringEntity(请求,HTTP.UTF_8);
DefaultHttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(新的URI(“http://xxxxxxxx.com/Storefront.asmx"));
addHeader(“内容类型”,“text/xml;charset=utf-8”);
addHeader(“SOAPAction”,SOAPAction);
httpPost.setEntity(se);
HttpResponse response=client.execute(httpPost);
int responseStatusCode=response.getStatusLine().getStatusCode();
Log.d(标记“HTTP状态代码:”+responseStatusCode);
如果(responseStatusCode>=200&&responseStatusCode我对KSoap2有另一个问题。不幸的是,KSoap2库不能与我的Web服务一起工作。因此,我最终完成了默认http post
我希望这将有助于在未来的人
private String makeHttpRequest(){
try{
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://tempuri.org/\">"
+"<SOAP-ENV:Body>"
+ "<ns1:Connect>"
+ "<ns1:lstr_Login>xxxxx</ns1:lstr_Login>"
+"</ns1:Connect>"
+"</SOAP-ENV:Body>"
+"</SOAP-ENV:Envelope>";
String soapAction = "http://tempuri.org/Connect"; //this would be your soapAction from wsdl
StringEntity se = new StringEntity(request, HTTP.UTF_8);
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(new URI("http://xxxxxxxx.com/Storefront.asmx"));
httpPost.addHeader("Content-Type", "text/xml; charset=utf-8");
httpPost.addHeader("SOAPAction", soapAction);
httpPost.setEntity(se);
HttpResponse response = client.execute(httpPost);
int responseStatusCode = response.getStatusLine().getStatusCode();
Log.d(TAG, "HTTP Status code:"+responseStatusCode);
if(responseStatusCode>=200 && responseStatusCode<300){
//we got the success response from server. Now retrieve the value and go for usage.
String responseStr = EntityUtils.toString(response.getEntity());
//use this responseStr to parse with pullparsers or any
Log.d("Response", "Response:: "+ responseStr);
return responseStr;
}
}catch(Exception e){
//Write the proper catch blocks for exceptions
Log.e("Response Exception" , e.getMessage()+"",e);
}
return null;
}
私有字符串makeHttpRequest(){
试一试{
String request=“”
+""
+ ""
+“xxxxx”
+""
+""
+"";
字符串soapAction=”http://tempuri.org/Connect“;//这将是wsdl中的soapAction
StringEntity se=新的StringEntity(请求,HTTP.UTF_8);
DefaultHttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(新的URI(“http://xxxxxxxx.com/Storefront.asmx"));
addHeader(“内容类型”,“text/xml;charset=utf-8”);
addHeader(“SOAPAction”,SOAPAction);
httpPost.setEntity(se);
HttpResponse response=client.execute(httpPost);
int responseStatusCode=response.getStatusLine().getStatusCode();
Log.d(标记“HTTP状态代码:”+responseStatusCode);
如果(responseStatusCode>=200&&responseStatusCode)您是如何确定它慢的?对我来说肯定不慢。在这一行->androidHttpTransport.call(SOAP\U操作,信封);它很慢,占用了大约10 mb的内存。有什么建议吗?你是如何确定它慢的?对我来说肯定不慢。在这行->androidHttpTransport.call(SOAP_操作,信封);它很慢,占用了大约10 mb的内存。有什么建议吗?如何在httpPost中发送SOAP xml头?如何在httpPost中发送SOAP xml头?