答案 0 :(得分:0)
使用KSoap library,这是我项目的代码段:
SoapObject soapObject = new SoapObject(NAMESPACE_NIST_IMPORT,
METHOD_NAME_NIST_IMPORT);
ImportNistFileReq nistReq = new ImportNistFileReq(nistFile);
PropertyInfo pi = new PropertyInfo();
pi.setName("req");
pi.setValue(nistReq);
pi.setType(nistReq.getClass());
soapObject.addProperty(pi);
SoapSerializationEnvelope soapSerializationEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
new MarshalBase64().register(soapSerializationEnvelope);
soapSerializationEnvelope.setOutputSoapObject(soapObject);
soapSerializationEnvelope.addMapping(NAMESPACE_NIST_IMPORT, "ImportNistFileReq", new ImportNistFileReq().getClass());
soapSerializationEnvelope.dotNet = true;
Object objectResult = null;
try {
HttpTransportSE httpTransportSE = new HttpTransportSE(
URL_NIST_IMPORT);
httpTransportSE.debug = true;
httpTransportSE.call(SOAP_ACTION_NIST_IMPORT, soapSerializationEnvelope);
String host = httpTransportSE.getPath();
Log.i("HOST: ", host);
objectResult = (Object) soapSerializationEnvelope.getResponse();
} catch (IOException e) {
Log.e("IO: ", e.getMessage());
} catch (XmlPullParserException e) {
Log.e("XML: ", e.getMessage());
}
这段代码向网络服务发送一个NIST File,表示为byte array
,编码为Byte64
。像这样的请求应该在像AsyncTask ..
常数: