android soap webservers 无法执行 报错 ht.call(SOAP_ACTION, envelope);解决方法
来源:互联网 发布:淘宝网鞋子男士 编辑:程序博客网 时间:2024/05/02 22:49
1.可能没有加入网络访问权限,在Manifest里面加入,<uses-permission android:name="android.permission.INTERNET"/>View Code
2.版本问题,很可能的问题,因为在android高于9的会出错,所以简单粗暴的办法就是,直接将版本信息
<uses-sdk
android:minSdkVersion="?"
android:targetSdkVersion="?"
/>
删除即可。
其他具体参考代码如下:
1 package com.example.soaptestforandroid; 2 3 import java.io.IOException; 4 5 import org.ksoap2.SoapEnvelope; 6 import org.ksoap2.serialization.SoapObject; 7 import org.ksoap2.serialization.SoapSerializationEnvelope; 8 import org.ksoap2.transport.HttpTransportSE; 9 import org.xmlpull.v1.XmlPullParserException;10 11 import android.os.*;12 import android.annotation.SuppressLint;13 import android.app.Activity;14 import android.util.Log;15 import android.view.Menu;16 import android.widget.*;17 18 public class MainActivity extends Activity19 {20 21 private static final String SERVICE_NAMESPACE = "http://services.jason.com/";22 private static final String SERVICE_URL = "http://172.16.1.164:8080/MyWebServer/UserInfoPort?wsdl";23 private EditText tv = null;24 25 26 27 @SuppressLint("NewApi")28 @Override29 protected void onCreate(Bundle savedInstanceState)30 {31 super.onCreate(savedInstanceState);32 setContentView(R.layout.activity_main);33 34 35 try {36 tv = (EditText) findViewById(R.id.hello);37 38 //如果本系统为4.0以上(Build.VERSION_CODES.ICE_CREAM_SANDWICH为android4.0)39 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {40 // 详见StrictMode文档41 StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()42 .detectDiskReads().detectDiskWrites().detectNetwork()43 .penaltyLog().build());44 StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()45 .detectLeakedSqlLiteObjects().detectLeakedClosableObjects()46 .penaltyLog().penaltyDeath().build());47 }48 49 // 调用的方法50 String mathodName = "GetUserInfo";51 String SOAP_ACTION = SERVICE_NAMESPACE + mathodName;52 // 创建HttpTransportSE对象53 HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);54 55 ht.debug = true;56 // 使用soap协议创建Envelop对象57 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(58 SoapEnvelope.VER10);59 // 实例化SoapObject对象60 SoapObject object = new SoapObject(SERVICE_NAMESPACE, mathodName);61 // 将SoapObject对象设置为SoapSerializationEnvelope对象的传出SOAP消息62 envelope.bodyOut = object;63 envelope.dotNet = true;64 envelope.setOutputSoapObject(object);65 // 调用webService66 ht.call(SOAP_ACTION, envelope);67 System.out.println("envelope.getResponse()---"68 + envelope.getResponse());69 if (envelope.getResponse()!= null) {70 71 SoapObject result = (SoapObject) envelope.bodyIn;72 String name = result.getProperty(0).toString();73 System.out.println(name);74 tv.setText("返回值为:" + name);75 76 } else {77 tv.setText("无返回值");78 }79 } catch (Exception e) {80 // TODO Auto-generated catch block81 e.printStackTrace();82 } 83 84 }85 86 @Override87 public boolean onCreateOptionsMenu(Menu menu)88 {89 // Inflate the menu; this adds items to the action bar if it is present.90 getMenuInflater().inflate(R.menu.main, menu);91 return true;92 }93 94 }
0 0
- android soap webservers 无法执行 报错 ht.call(SOAP_ACTION, envelope);解决方法
- SOAP Envelope 元素
- CentOS上执行android中mkscard报错的解决方法
- IDEA/Android Studio报Ambiguous method call的一种解决方法
- SOAP学习(一):SOAP Envelope 元素
- Android自定义Dialog二次调用报错解决方法:The specified child already has a parent. You must call removeView()
- Android AlertDialog嵌套及二调用报错解决方法:The specified child already has a parent. You must call removeView()
- centos7执行ifconfig报错解决方法
- Android depencies报错解决方法
- Call call=(Call)service.createCall()报错
- 调用JOB执行外部脚本报错ORA-27369解决方法
- linux启动jmeter,执行./jmeter.sh报错解决方法
- 执行python脚本报错No module named requests解决方法
- 安装redis-执行make命令报错解决方法
- PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
- PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
- PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
- {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 错误解决
- AOP面向方面(切面)编程
- spring in action-最小化spring XML配置
- 关于类和接口的一些小笔记
- #1045 - Access denied for user 'root'@'localhost' (using password: NO)的问题
- cas报错 数据源没有找到
- android soap webservers 无法执行 报错 ht.call(SOAP_ACTION, envelope);解决方法
- Xcode如何打包ipa安装包
- Find that single one.(linear runtime complexity0
- 获取Android Activity两种方法
- 尼姆游戏(吃花生米问题)
- Laravel 5 Form 和 HTML 的使用
- LoadBitmap(IDB_BITMAP1) -- 未定义标识符 IDB_BITMAP1
- Reverse Integer
- String to Integer (atoi)