2

每次我上传一个新对象时,它都会向数据库提交一个空对象并忽略我为其设置的所有参数。

这是安卓端:

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>

关于为什么不使用组名参数上传整个对象的任何建议?

4

2 回答 2

2

用这个

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addproperty("arg0",gr);

也不要忘记在方法中添加这个 -

void customMethod(@WebParam(name = "arg0")String arg0)
于 2012-12-22T11:01:52.550 回答
0

好的,我已经解决了这个问题。我没有实现KvmSerializable接口的方法-

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

此外,我将我的肥皂对象请求作为一个单独的类,因为它对我不起作用MainActivity

于 2012-12-22T11:30:41.067 回答