每當我上傳一個新的Object時,它向數據庫提交一個空對象並忽略我設置的所有參數。在android中使用ksoap2上傳的空物體
下面是Android的一面:
public void createGroupServ(String groupName)
{
request = new SoapObject(NAMESPACE, "createGroup");
Group gr = new Group();
gr.setGroupId(1L);
gr.setGroupName("xxxx");
gr.setUsers(null);
PropertyInfo object = new PropertyInfo();
object.setName("arg0");
object.setValue(gr);
object.setType(gr.getClass());
request.addProperty(object);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE, "group", new Group().getClass());
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
}
和域類組:
public class Group implements KvmSerializable {
private long groupId;
private String groupName;
private List<User> users = null;
...setter and getters ...
}
我的WSDL的xml:
<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="createGroup">
<xs:sequence>
<xs:element name="arg0" type="tns:group" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
爲什麼它沒有按任何意見上傳整個對象t與組名參數?
你可能會得到android.os.NetworkOnMainThreadException.Try在asynctask中調用你的soap對象請求,或者在你的主要活動中使用這個代碼。 'StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()。permitAll()。build(); StrictMode.setThreadPolicy(policy);' – mjosh