android使用ksoap2调用sap的webservice
1 public void on_clicked(View view) { 2 Thread webserviceThread = new Thread() 3 4 { 5 6 public void run() { 7 String NAMESPACE = "urn:sap-com:document:sap:rfc:functions"; 8 String METHOD_NAME = "ZSAP_ERP_001"; 9 String SOAP_ACTION = "urn:sap-com:document:sap:rfc:functions:ZSAP_ERP_001:ZSAP_ERP_001Request"; 10 String URL = "http://172.16.1.7:8000//sap/bc/srt/rfc/sap/zsap_erp_001/400/zsap_erp_001/zsap_erp_001"; 11 12 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 13 // Set all input params 14 // SoapObject so = new SoapObject("","ET_QMERP"); 15 SoapObject so = request.addProperty("ET_QMERP",""); 16 SoapObject so1 = new SoapObject("","IT_BUDAT"); 17 so1.addProperty("SIGN","I"); 18 so1.addProperty("LOW","20161129"); 19 so1.addProperty("HIGH",""); 20 so1.addProperty("OPTION","EQ"); 21 SoapObject so2 = new SoapObject("","IT_EBELN"); 22 so2.addProperty("SIGN",""); 23 so2.addProperty("LOW",""); 24 so2.addProperty("HIGH",""); 25 so2.addProperty("OPTION",""); 26 SoapObject so3 = new SoapObject("","IT_LIFNR"); 27 so3.addProperty("SIGN",""); 28 so3.addProperty("LOW",""); 29 so3.addProperty("HIGH",""); 30 so3.addProperty("OPTION",""); 31 SoapObject so4 = new SoapObject("","IT_MATNR"); 32 so4.addProperty("SIGN","I"); 33 so4.addProperty("LOW","000000164076005800"); 34 so4.addProperty("HIGH",""); 35 so4.addProperty("OPTION","EQ"); 36 request.addSoapObject(so1); 37 request.addSoapObject(so2); 38 request.addSoapObject(so3); 39 request.addSoapObject(so4); 40 41 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 42 // Enable the below property if consuming .Net service 43 envelope.dotNet = false; 44 45 envelope.setOutputSoapObject(request); 46 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 47 try { 48 List<HeaderProperty> headerList = new ArrayList<HeaderProperty>(); 49 headerList.add(new HeaderProperty("Authorization", "Basic " + org.kobjects.base64.Base64.encode("at-tanghh:huanhuan".getBytes()))); 50 51 androidHttpTransport.call(SOAP_ACTION, envelope, headerList); 52 SoapObject response = (SoapObject) envelope.getResponse(); 53 //response.getProperty(0).toString(); 54 } catch (Exception e) { 55 e.printStackTrace(); 56 } 57 } 58 }; 59 webserviceThread.start(); 60 }