KSOAP を使用して Android で次の SOAP リクエストを実行しようとしています。ネストされた SOAP オブジェクトのリストが含まれています。ただし、エラーが返されるので、何か間違ったことをしているに違いありません。
生成しようとしているリクエストは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<SetAttendanceMarks xmlns="http://hostname.net/">
<strSessionToken>string</strSessionToken>
<LessonMarks>
<Count>int</Count>
<LessonMarks>
<LessonMark>
<StudentId>int</StudentId>
<EventInstanceId>int</EventInstanceId>
<Mark>string</Mark>
</LessonMark>
<LessonMark>
<StudentId>int</StudentId>
<EventInstanceId>int</EventInstanceId>
<Mark>string</Mark>
</LessonMark>
</LessonMarks>
</LessonMarks>
</SetAttendanceMarks>
</soap12:Body>
</soap12:Envelope>
私のコードは次のとおりです。
public boolean setAttendanceMarks(List<Mark> list) throws Exception
{
boolean result = false;
String methodName = "SetAttendanceMarks";
String soapAction = getHost() + "SetAttendanceMarks";
SoapObject lessMarksN = new SoapObject(getHost(), "LessonMarks");
for (Mark m : list)
{
PropertyInfo smProp =new PropertyInfo();
smProp.setName("LessonMark");
smProp.setValue(m);
smProp.setType(Mark.class);
lessMarksN.addProperty(smProp);
}
PropertyInfo cProp =new PropertyInfo();
cProp.setName("Count");
cProp.setValue(list.size());
cProp.setType(Integer.class);
SoapObject lessMarks = new SoapObject(getHost(), "LessonMarks");
lessMarks.addProperty(cProp);
lessMarks.addSoapObject(lessMarksN);
PropertyInfo sProp =new PropertyInfo();
sProp.setName("strSessionToken");
sProp.setValue(mSession);
sProp.setType(String.class);
SoapObject request = new SoapObject(getHost(), methodName);
request.addProperty(sProp);
request.addSoapObject(lessMarks);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(getURL());
androidHttpTransport.debug = true;
androidHttpTransport.call(soapAction, envelope);
String a = androidHttpTransport.requestDump;
String b = androidHttpTransport.responseDump;
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
SoapObject res = (SoapObject) resultsRequestSOAP.getProperty(0);
String resultStr = res.getPropertyAsString("Result");
if (resultStr.contentEquals("OK"))
{
result = true;
}
return result;
}
私が得るエラーは次のとおりです。
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Server was unable to read request. ---> There is an error in XML document (1, 383). ---> The specified type was not recognized: name='LessonMarks', namespace='http://gsdregapp.net/', at <LessonMarks xmlns='http://gsdregapp.net/'>.</soap:Text>
</soap:Reason>
<soap:Detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
誰が私が間違っているのか教えてもらえますか? どんな支援にも感謝します!