} private List connectWebService (String fileName2) { / / TODO Auto-generated method stub / / Use ksoap2 call webservice String namespace = "http://localhost/WebServiceLearn"; / / Namespace that the server was interfaces Note: suffix did not add wsdl, . / / Server side I am using c # to achieve webservice interfaceString url = "http://localhost/WebServiceLearn/Service1.asmx?wsdl"; / / SOAP Action String soapAction = "http://localhost/WebServiceLearn/UploadAndroidFile";
/ / Specify WebService namespace and method name to call SoapObject soapObject = new SoapObject (namespace, methodName); soapObject.addProperty ("FileName", fileName2); / / parameter a file name / / Generate method call WebService SOAP request message. This information is described by SoapSerializationEnvelope object SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER10); envelope.bodyOut = soapObject; . (New MarshalBase64 ()) register (envelope); envelope.dotNet = true; / / This property is supported dotnetwebservice attributes, if you do not specify rpc dotnetwebservice way, true, or is false
envelope.setOutputSoapObject (soapObject);
/ / Instantiate a HttpTransportSE object to call web service, and get the xml string data HttpTransportSE httpTranstation = new HttpTransportSE (url); httpTranstation.debug = true ;/ / if it is in debug mode
try { httpTranstation.call (soapAction, envelope); SoapObject result = (SoapObject) envelope.getResponse (); / / The following results were parsed structure similar to json object int count = result.getPropertyCount (); for (int index = 0; index checkinfos.add (result.getProperty (index) toString ().); } } Catch (IOException e) { e.printStackTrace (); } Catch (XmlPullParserException e) { e.printStackTrace (); }
return checkinfos; }
} Each run to SoapObject result = (SoapObject) envelope.getResponse (); went IOException e Department reported SoapFault - faultcode: 'soap: Client' faultstring: 'Server does not recognize the value of HTTP Header SOAPAction:. 'Faultactor:' null 'detail: org.kxml2.kdom.Node @ 4056e118 error, try a variety of methods will not work, very anxious, heroes who help to look at, very grateful. Reply: You can try to visit this part of the code WEBSERVICE, put thread calls; Sometimes android version higher. Visit INTENT need to thread access. Reply: My web service returns a dataset, android in then parse it? This issue is full for several days, have a big head, big God help me find it. Reply:
WS client should not return dataset, it seems like android terminal handling problems; You should convert WS client dataset remove data into JSON data format or XML data format, and then return to the android side, so that resolve relatively simpler. Reply:
You can try to visit this part of the code WEBSERVICE, put thread calls; Sometimes android version higher. Visit INTENT need to thread access.
My web service returns a dataset, android in then parse it? This issue is full for several days, have a big head, big God help me find it.
WS client should not return dataset, it seems like android terminal handling problems; You should convert WS client dataset remove data into JSON data format or XML data format, and then return to the android side, so that resolve relatively simpler.
At present, the problem has been solved, the solution posted for newcomers learn: After 1.web service returns a value of type string, which parameters (string Filename, byte [] data) which byte [] is passed over from the android in a byte array, filename is passed to upload files on the server names. 2, in the android side, String uploadBuffer = new String (Base64.encode (baos.toByteArray (), count)); / / perform Base64 encoding code to remove this one, plus buffer = baos.toByteArray (); connectWebServicetwo (fileName, buffer); 3 In connectWebServicetwo function, try catch in to try { httpTranstation.call (soapAction, envelope); org.ksoap2.serialization.SoapPrimitive so = (org.ksoap2.serialization.SoapPrimitive) envelope.getResponse (); / / Object so = (Object) envelope.bodyIn; ret = Boolean.valueOf (so.toString ()); return ret;
} Catch (Exception e) { e.printStackTrace (); } Red font is a key part. After this modification to normal operation. I am grateful enthusiastic users answer.
No comments:
Post a Comment