我开发了一个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