如何在Android中使用SOAP服务的DataSet响应?

时间:2014-09-18 08:42:59

标签: android sqlite android-ksoap2

我在许多Android应用程序中一直使用基于SOAP的服务,它们总能正常工作(通常是字符串输出)。但是,我遇到了一个接受DataSet和SQL Query作为输入的服务,并将DataSet作为输出返回。

据我所知,Android中没有DataSet对象类型。我的问题是,我们如何在Android中使用这样的服务?甚至可以这样做吗?

以下是该服务的快照:

enter image description here

1 个答案:

答案 0 :(得分:0)

很高兴为您服务,您可以将Android与ASP.NET连接,以便您可以从SOAP WebService读取DataSET

我会给一个片段

public class CallSoap 
{
public final String SOAP_ACTION = "http://tempuri.org/Add";

public  final String OPERATION_NAME = "Add"; 

public  final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

public  final String SOAP_ADDRESS = "http://yoururl/File.asmx";
public CallSoap() 
{ 
}
public String Call(int a,int b)
{
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi=new PropertyInfo();
pi.setName("a");
        pi.setValue(a);
        pi.setType(Integer.class);
        request.addProperty(pi);
        pi=new PropertyInfo();
        pi.setName("b");
        pi.setValue(b);
        pi.setType(Integer.class);
        request.addProperty(pi);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;
try
{
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
}
catch (Exception exception)
{
response=exception.toString();
}
return response.toString();
}
}
First SOAP_ACTION = namespace as seen in figure 1+function name;
OPERATION_NAME = name of the web method;
WSDL_TARGET_NAMESPACE = namespace of the webservice;
SOAP_ADDRESS = absolute URL of the webservice;