正试图连接到一个Web服务,以检索一些数据与Android设备与KSOAP2。我认为我有使配置正确,并且我从Web服务后面的结果anyType的{},我使用的代码是低于ksoap在Android与.net
private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String URL = "http://IP/CardiacPortalWS/VitalInfoWS.asmx";
private static final String HelloWorld_SOAP_ACTION = "http://tempuri.org/getPatient";
private static final String METHOD_NAME1 = "getPatient";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("patientID",8);
SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug=true;
SoapObject receivedString=null;
try
{
androidHttpTransport.call(HelloWorld_SOAP_ACTION, envelope);
receivedString = (SoapObject)envelope.getResponse();
Log.v("Server", "server data1 "+receivedString.getPropertyCount());
Log.i("Server", "server data2 "+receivedString.getProperty(0));
}
catch(Exception e)
{ }
的SOAP文件是
的SOAPAction : “http://tempuri.org/getPatient”
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getPatient xmlns="http://tempuri.org/">
<patientID>int</patientID>
<name>string</name>
<SID>string</SID>
<sex>boolean</sex>
<birthday>dateTime</birthday>
<nationality>string</nationality>
<telephone>string</telephone>
<telephone1>string</telephone1>
<email>string</email>
<maritalStatusName>string</maritalStatusName>
<educationName>string</educationName>
<ejectionFraction>int</ejectionFraction>
<profession>string</profession>
<deathDateTime>dateTime</deathDateTime>
<deathReason>string</deathReason>
<isDead>boolean</isDead>
</getPatient>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getPatientResponse xmlns="http://tempuri.org/">
<getPatientResult>
<message>string</message>
<code>int</code>
</getPatientResult>
<name>string</name>
<SID>string</SID>
<sex>boolean</sex>
<birthday>dateTime</birthday>
<nationality>string</nationality>
<telephone>string</telephone>
<telephone1>string</telephone1>
<email>string</email>
<maritalStatusName>string</maritalStatusName>
<educationName>string</educationName>
<ejectionFraction>int</ejectionFraction>
<profession>string</profession>
<deathDateTime>dateTime</deathDateTime>
<deathReason>string</deathReason>
<isDead>boolean</isDead>
</getPatientResponse>
</soap:Body>
</soap:Envelope>
我假定,这个问题是在此行request.addProperty( “patientID”,8);但我不确定。存在于服务器上的数据是因为能够看到它们。 我会感谢一些帮助,想法或更详细的教程
对不起......什么是乌拉圭回合的问题? – 2012-01-12 06:37:48
我的问题是,我没有得到任何结果。如果我写错拼错了patientID或我,如果我写错了身份证号码我的结果是:anyType {message =病人ID不存在;代码= -1; }我认为直到这一点我继续getPatient XML并找到正确的结果。当我在字段pathientID上添加正确的信息时,我得到的结果是:anyType {message = anyType {};代码= 0; } – prokopis 2012-01-12 08:14:15
这个错误是由webSevice返回的意思是在服务器端有一些错误。并检查一次哪个参数是可选的(非空) – 2012-01-12 08:18:17