我在查找如何在Android中调用标准SOAP Web服务方面遇到很多麻烦。任何帮助
答案 0 :(得分: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;
}
答案 1 :(得分:0)
首先,您应该通过AsyncTask调用Web服务。 您必须具有bean类并在清单文件中添加Internet权限。 查看this Example以获取参考资料