我很难找到有关如何在 Android 中调用标准 SOAP Web 服务的好信息。任何帮助
问问题
436 次
2 回答
0
使用下面的代码使用NTLM AUTHENTICATION从 Android 调用 SOAP Web 服务。
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.implicitTypes = true;
soapEnvelope.dotNet = true;
SoapObject soapReq = new SoapObject("urn:microsoft-dynamics-schemas/page/customercard","Read");
soapEnvelope.setOutputSoapObject(soapReq);
propinfo = new PropertyInfo();
propinfo.setName("No");
propinfo.setValue(no);
propinfo.setType(no.getClass());
propinfo.setNamespace("urn:microsoft-dynamics-schemas/page/customercard");
soapReq.addProperty(propinfo);
NtlmTransport ntlm = new NtlmTransport(url, userid, password, domainname,systemname);
try{
if (headers!=null){
ntlm.call("urn:microsoft-dynamics-schemas/page/customercard/Read", soapEnvelope,headers);
}else{
ntlm.call("urn:microsoft-dynamics-schemas/page/customercard/Read", soapEnvelope);
}
Object retObj = soapEnvelope.bodyIn;
if (retObj instanceof SoapFault){
SoapFault fault = (SoapFault)retObj;
Exception ex = new Exception(fault.faultstring);
if (eventHandler != null)
eventHandler.Wsdl2CodeFinishedWithException(ex);
}else{
SoapObject result=(SoapObject)retObj;
if (result.getPropertyCount() > 0){
System.out.println("RESULT 2"+result);
Object obj = result.getProperty(0);
SoapObject j = (SoapObject)obj;
}
于 2014-02-17T11:01:25.967 回答
0
首先,您应该通过 AsyncTask 调用 Web 服务。您必须有一个 bean 类并在清单文件中添加 Internet 权限。检查此示例供您参考
于 2014-04-11T12:10:11.613 回答