我想使用 ksoap2 创建一个包含空列表的对象组。我设法使用 webservice 方法在独立应用程序上执行此操作,但是,使用 android 给我一个错误:java.lang.RuntimeException: Cannot serialize: []
我的问题,是否有解决此错误的方法?
这是我的WSDL
xml:
<xs:complexType name="createGroup">
<xs:sequence>
<xs:element name="new-group-object" type="tns:group" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="group">
<xs:sequence>
<xs:element name="groupId" type="xs:long"/>
<xs:element name="groupName" type="xs:string" minOccurs="0"/>
<xs:element name="users" type="tns:user" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="user">
<xs:sequence>
<xs:element name="latitude" type="xs:double"/>
<xs:element name="longitude" type="xs:double"/>
<xs:element name="userAge" type="xs:int"/>
<xs:element name="userId" type="xs:long"/>
<xs:element name="userName" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
和我的android客户端方法:
public void createGroupServ(String groupName)
{
request = new SoapObject(NAMESPACE, "createGroup");
SoapObject soapGroup = new SoapObject(NAMESPACE, "group");
Group gr = new Group();
gr.setGroupName(groupName);
gr.setUsers(new ArrayList<User>());
request.addProperty("new-group-object", gr);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
...
}