我開發了一個WCF服務.NET4(SOAP),我試圖從Android使用它。 但是,我得到這個錯誤的問題:上傳文件來自android使用WCF服務和Ksoap2
org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG @1:761 in [email protected])
在這一行:
androidHttpTransport.call(SOAP_ACTION, envelope);
這裏是我的代碼:
private static final String SOAP_ACTION = "http://tempuri.org/OCRWebService/extractText";
private static final String METHOD_NAME = "extractText";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://10.0.2.2/ocrwebservice/Service.svc";
private String extractText(byte[] _data){
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo p1=new PropertyInfo();
p1.setName("image2up");
p1.setType(_data);
request.addProperty(p1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug=true;
androidHttpTransport.call(SOAP_ACTION, envelope); // error here
SoapObject result=(SoapObject)envelope.getResponse();
String resultData=result.getProperty(0).toString();
} catch (Exception e) {
Log.i("123",e.getMessage());
}
return "false";
}
(供參考:我想要使用wcf servcice從Android設備上傳文件到我的服務器)
這是多餘的,但將工作。 – 2013-06-19 07:01:33