在使用eclipse创建apk应用程序时,报错了! 报错的地方为: SoapObject request = new SoapObject(NAMESPACE, methodName); 下面是我的webservice的?wsdl This XML file does not appear to have any style @R_170_4045@ion associated with it. The document tree is shown below. < wsdl:deFinitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://database.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://sql.java/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://database.com"> < wsdl:documentation>JDBCDatabaseService</wsdl:documentation> < wsdl:types> < xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://sql.java/xsd"> < xs:complexType name="sqlException"> < xs:sequence> < xs:element minOccurs="0" name="sqlState" nillable="true" type="xs:string"/> < xs:element minOccurs="0" name="errorCode" type="xs:int"/> < xs:element minOccurs="0" name="nextException" nillable="true" type="ax21:sqlException"/> < /xs:sequence> < /xs:complexType> < /xs:schema> < xs:schema xmlns:ax22="http://sql.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://database.com"> < xs:import namespace="http://sql.java/xsd"/> < xs:element name="JDBCDatabaseServicesqlException"> < xs:complexType> < xs:sequence> < xs:element minOccurs="0" name="sqlException" nillable="true" type="ax21:sqlException"/> < /xs:sequence> < /xs:complexType> < /xs:element> < xs:element name="executeQueryStr"> < xs:complexType> < xs:sequence> < xs:element minOccurs="0" name="sql" nillable="true" type="xs:string"/> < /xs:sequence> < /xs:complexType> < /xs:element> < xs:element name="executeQueryStrResponse"> < xs:complexType> < xs:sequence> < xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/> < /xs:sequence> < /xs:complexType> < /xs:element> < /xs:schema> < /wsdl:types> < wsdl:message name="executeQueryStrRequest"> < wsdl:part name="parameters" element="ns:executeQueryStr"/> < /wsdl:message> < wsdl:message name="executeQueryStrResponse"> < wsdl:part name="parameters" element="ns:executeQueryStrResponse"/> < /wsdl:message> < wsdl:message name="JDBCDatabaseServicesqlException"> < wsdl:part name="parameters" element="ns:JDBCDatabaseServicesqlException"/> < /wsdl:message> < wsdl:portType name="JDBCDatabaseServicePortType"> < wsdl:operation name="executeQueryStr"> < wsdl:input message="ns:executeQueryStrRequest" wsaw:Action="urn:executeQueryStr"/> < wsdl:output message="ns:executeQueryStrResponse" wsaw:Action="urn:executeQueryStrResponse"/> < wsdl:fault message="ns:JDBCDatabaseServicesqlException" name="JDBCDatabaseServicesqlException" wsaw:Action="urn:executeQueryStrJDBCDatabaseServicesqlException"/> < /wsdl:operation> < /wsdl:portType> < wsdl:binding name="JDBCDatabaseServiceSoap11Binding" type="ns:JDBCDatabaseServicePortType"> < soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> < wsdl:operation name="executeQueryStr"> < soap:operation soapAction="urn:executeQueryStr" style="document"/> < wsdl:input> < soap:body use="literal"/> < /wsdl:input> < wsdl:output> < soap:body use="literal"/> < /wsdl:output> < wsdl:fault name="JDBCDatabaseServicesqlException"> < soap:fault use="literal" name="JDBCDatabaseServicesqlException"/> < /wsdl:fault> < /wsdl:operation> < /wsdl:binding> < wsdl:binding name="JDBCDatabaseServiceSoap12Binding" type="ns:JDBCDatabaseServicePortType"> < soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> < wsdl:operation name="executeQueryStr"> < soap12:operation soapAction="urn:executeQueryStr" style="document"/> < wsdl:input> < soap12:body use="literal"/> < /wsdl:input> < wsdl:output> < soap12:body use="literal"/> < /wsdl:output> < wsdl:fault name="JDBCDatabaseServicesqlException"> < soap12:fault use="literal" name="JDBCDatabaseServicesqlException"/> < /wsdl:fault> < /wsdl:operation> < /wsdl:binding> < wsdl:binding name="JDBCDatabaseServiceHttpBinding" type="ns:JDBCDatabaseServicePortType"> < http:binding verb="POST"/> < wsdl:operation name="executeQueryStr"> < http:operation location="executeQueryStr"/> < wsdl:input> < mime:content type="application/xml" part="parameters"/> < /wsdl:input> < wsdl:output> < mime:content type="application/xml" part="parameters"/> < /wsdl:output> < /wsdl:operation> < /wsdl:binding> < wsdl:service name="JDBCDatabaseService"> < wsdl:port name="JDBCDatabaseServiceHttpSoap11Endpoint" binding="ns:JDBCDatabaseServiceSoap11Binding"> < soap:address location="http://10.57.253.249:8080/axis2/services/JDBCDatabaseService.JDBCDatabaseServiceHttpSoap11Endpoint/"/> < /wsdl:port> < wsdl:port name="JDBCDatabaseServiceHttpSoap12Endpoint" binding="ns:JDBCDatabaseServiceSoap12Binding"> < soap12:address location="http://10.57.253.249:8080/axis2/services/JDBCDatabaseService.JDBCDatabaseServiceHttpSoap12Endpoint/"/> < /wsdl:port> < wsdl:port name="JDBCDatabaseServiceHttpEndpoint" binding="ns:JDBCDatabaseServiceHttpBinding"> < http:address location="http://10.57.253.249:8080/axis2/services/JDBCDatabaseService.JDBCDatabaseServiceHttpEndpoint/"/> < /wsdl:port> < /wsdl:service> < /wsdl:deFinitions> 函数调用代码: private String getRequest(){ String str = ""; try { //第1步:先定义要访问的webservice相关的几个参数 // 定义webservice的URL,注意不包括?wsdl或.aar,对应文件里的documentation字段 String serviceUrl = "http://10.57.253.249:8080/axis2/services/JDBCDatabaseService"; //定义命名空间,对应targetNamespace字段 String NAMESPACE = "http://database.com"; //定义要调用的WebService方法名 String methodName = "executeQueryStr"; String SOAP_ACTION = "http://database.com/executeQueryStr"; //第2步:根据WebService的命名空间和调用的方法名 创建SoapObject对象, SoapObject request = new SoapObject(NAMESPACE, methodName); //第3步:设置WebService方法的参数 ,参数名可以不一样,但顺序要一致 String strParam = "select FDAName from SystemParameter"; request.addProperty("sql",strParam ); //第4步:创建soap序列化封装对象:SoapSerializationEnvelope,并指定WebService的版本 //版本要对应wsdl文件里的soap版本 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //设置soap序列化封装对象属性 envelope.bodyOut = request;//也可通过 setoutputSoapObject来设置 envelope.dotNet = true; //第5步:根据webservice的URL创建HttpTransportSE对象(通过HTTP协议传输soap序列化对象) HttpTransportSE ht = new HttpTransportSE(serviceUrl); ht.debug = true; //第6步:开始调用,soap版本不一致时会出现异常 //同步调用,实际处理的时候,要起个线程处理 ht.call(SOAP_ACTION, envelope); //第7步获取返回结果,有两种方法,此处用bodyIn,有时出现异常可能是webservice端的方法有问题造成的 //getResponse好像有问题,据说是服务端没搞定的原因,此处不在深究 SoapObject soapObject = (SoapObject) envelope.bodyIn; //SoapObject soapObject =(SoapObject)envelope.getResponse(); System.out.println("soapObject" + soapObject); Toast.makeText(this, soapObject.toString(), Toast.LENGTH_LONG).show(); //获取返回的内容 str = soapObject.getProperty("return").toString(); } 报错日志: 11-14 03:48:30.463: E/AndroidRuntime(885): FATAL EXCEPTION: main 11-14 03:48:30.463: E/AndroidRuntime(885): Process: com.example.helloworld, PID: 885 11-14 03:48:30.463: E/AndroidRuntime(885): java.lang.IllegalStateException: Could not execute method of the activity 11-14 03:48:30.463: E/AndroidRuntime(885): at android.view.View$1.onClick(View.java:3814) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.view.View.performClick(View.java:4424) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.view.View$PerformClick.run(View.java:18383) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.os.Handler.handleCallback(Handler.java:733) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.os.Handler.dispatchMessage(Handler.java:95) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.os.Looper.loop(Looper.java:137) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.app.ActivityThread.main(ActivityThread.java:4998) 11-14 03:48:30.463: E/AndroidRuntime(885): at java.lang.reflect.Method.invokeNative(Native Method) 11-14 03:48:30.463: E/AndroidRuntime(885): at java.lang.reflect.Method.invoke(Method.java:515) 11-14 03:48:30.463: E/AndroidRuntime(885): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 11-14 03:48:30.463: E/AndroidRuntime(885): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 11-14 03:48:30.463: E/AndroidRuntime(885): at dalvik.system.NativeStart.main(Native Method) 11-14 03:48:30.463: E/AndroidRuntime(885): Caused by: java.lang.reflect.InvocationTargetException 11-14 03:48:30.463: E/AndroidRuntime(885): at java.lang.reflect.Method.invokeNative(Native Method) 11-14 03:48:30.463: E/AndroidRuntime(885): at java.lang.reflect.Method.invoke(Method.java:515) 11-14 03:48:30.463: E/AndroidRuntime(885): at android.view.View$1.onClick(View.java:3809) 11-14 03:48:30.463: E/AndroidRuntime(885): ... 11 more 11-14 03:48:30.463: E/AndroidRuntime(885): Caused by: java.lang.NoClassDefFoundError: org.ksoap2.serialization.soapObject 11-14 03:48:30.463: E/AndroidRuntime(885): at com.example.helloworld.MainActivity.getRequest(MainActivity.java:73) 11-14 03:48:30.463: E/AndroidRuntime(885): at com.example.helloworld.MainActivity.onClick_Event(MainActivity.java:46) 11-14 03:48:30.463: E/AndroidRuntime(885): ... 14 more
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。