我从Android发送到我的Webservice(.NET)我的对象,但Webservice告诉我他没有收到任何东西。我不知道问题出在哪里 - 这是关于Android还是Webservice?
方法等应该没问题,因为我能够从Webservice接收项目。我的方法看起来很好,不会抛出任何错误。
myMethod的
final String METHOD_NAME = "SetMyProduct";
final String SOAP_ACTION = "http://tempuri.org/IService1/SetMyProduct";
myAdd objToSend = new myAdd();
objToSend.setProperty(0, "aaa");
objToSend.setProperty(1, "bbb");
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("myAdd");
pi.setValue(objToSend);
pi.setType(myAdd.class);
request.addProperty(pi);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
//soapEnvelope.bodyOut = request;
soapEnvelope.addMapping(NAMESPACE, myAdd.class.getSimpleName(), myAdd.class);
Marshal floatMarshal = new MarshalFloat();
floatMarshal.register(soapEnvelope);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);//call the eb service Method
//Log.i("soapEnvelope", String.valueOf(soapEnvelope));
//Log.i("request", String.valueOf(request));
} catch (Exception e) {
Log.e("error", String.valueOf(e));
}
myAdd class
public class myAdd implements KvmSerializable {
String Nazwa;
String Nazwa2;
@Override
public Object getProperty(int arg0) {
switch (arg0){
case 0:
return Nazwa;
case 1:
return Nazwa2;
default:
return null;
}
}
@Override
public int getPropertyCount() {
return 2;//because you have 2 parameters
}
@Override
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
switch(arg0)
{
case 0:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "Nazwa";
break;
case 1:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "Nazwa2";
break;
default:break;
}
}
@Override
public void setProperty(int arg0, Object arg1) {
switch(arg0)
{
case 0:
Nazwa = (String)arg1;
break;
case 1:
Nazwa2 = (String)arg1;
break;
default:
break;
}
}
}