我已经为我的应用程序实现了许多 SOAP 函数,但现在我遇到了一些问题:
public int generatePost(String sid, int uid, int obj_id, int ref_id, int thr_pk,
String msg, int pos_pk, String title, String date)
{
int pos_pk_new = 0;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
SoapObject soapObject = new SoapObject("urn:ilUserAdministration", "generatePost");
soapObject.addProperty("sid", sid);
soapObject.addProperty("uid", uid);
soapObject.addProperty("obj_id", obj_id);
soapObject.addProperty("ref_id", ref_id);
soapObject.addProperty("thr_pk", thr_pk);
soapObject.addProperty("msg", msg);
soapObject.addProperty("pos_pk", pos_pk);
soapObject.addProperty("title", title);
soapObject.addProperty("date", date);
envelope.setOutputSoapObject(soapObject);
HttpTransportSE transport = new HttpTransportSE(PATH_TO_YOUR_ILIAS_INSTALLATION + "/webservice/soap/server.php");
transport.debug = true;
try
{
transport.call("generatePost", envelope);
pos_pk_new = Integer.parseInt(envelope.getResponse().toString());
return pos_pk_new;
}
catch (IOException e)
{ e.printStackTrace(); }
catch (XmlPullParserException e)
{ e.printStackTrace(); }
return 0;
}
像:PATH_TO_YOUR_ILIAS_INSTALLATION、urn:ilUserAdministration 等参数都可以。我还有其他运行良好的功能,但是这个会产生这个错误:
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG (empty) <br>@1:6 in java.io.InputStreamReader@44c45f52)
0
at org.kxml2.io.KXmlParser.exception(Unknown Source)
at org.kxml2.io.KXmlParser.require(Unknown Source)
at org.ksoap2.SoapEnvelope.parse(Unknown Source)
at org.ksoap2.transport.Transport.parseResponse(Unknown Source)
at org.ksoap2.transport.HttpTransportSE.call(Unknown Source)
at de.ilias.SOAPExample.generatePost(SOAPExample.java:1048)
at de.ilias.SOAPExample.main(SOAPExample.java:1473)
php 函数 generatePost 运行良好,因为我已经在 php 片段中对其进行了测试。
ksoap 库是否有可能对添加到我的 soapObject 的参数有限制?
谢谢。