每次我上传一个新的Object时,它都会向数据库提交一个空对象并忽略我设置的所有参数。
这是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>
关于为什么它不使用组名参数上传整个对象的任何建议?
答案 0 :(得分:2)
使用此
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addproperty("arg0",gr);
也不要忘记在方法中添加它 -
void customMethod(@WebParam(name = "arg0")String arg0)
答案 1 :(得分:0)
好的,我已经解决了这个问题。我没有实现KvmSerializable
interface -
public Object getProperty
public int getPropertyCount
public void getPropertyInfo
public void setProperty
可以在这里找到: http://seesharpgears.blogspot.co.uk/2010/10/ksoap-android-web-service-tutorial-with.html
此外,我将soap对象请求作为一个单独的类,因为它在我MainActivity
中不起作用。