在我的某个应用中,我想将Object
发送给WCF服务。这个Object
绑定了三个数据。我不知道如何发送它。
我试过了
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject map = new SoapObject(NAMESPACE, "New Role");
map.addProperty("RoleID", "ROLEAAAA0001");
map.addProperty("RoleName", "MOB_Gunaseelan");
map.addProperty("ActionBy", "Gunaseelan");
request.addSoapObject(map);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(URL);
try {
transport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapFault fault = (SoapFault) envelope.bodyIn;
System.out.println("Fault : " + fault.toString());
这样。在这里,我想将RoleID
,RoleName
,ActionBy
绑定为一个对象。在WCF服务中,我的同事将此对象转换为他的舒适对象,然后将其提取出来。所以我想绑定。有可能是朋友。如果可能,请指导我。
提前致谢。
答案 0 :(得分:2)
int ArryIndex = 0;
SoapObject soReturn ;
String [] ParameterName = new String[3];
String [] ParameterValue = new String[3];
ParameterName[0] = "RoleID";
ParameterValue[0] = ROLEAAAA0001;
ParameterName[1] = "RoleName";
ParameterValue[1] = MOB_Gunaseelan;
ParameterName[2] = "ActionBy";
ParameterValue[2] = Gunaseelan;
objWSConfig.SetURL(URL, WebService);
objWSConfig.SetSOAPAction(SoapAction, MethodName);
objWSConfig.SetWebService(WebService);
objWSConfig.SetMethod(MethodName);
ws_Method = objWSConfig.getMethod();
ws_Namespace = objWSConfig.getNamespace();
ws_URL = objWSConfig.getURL();
ws_SOAPAction = objWSConfig.getSOAPAction();
SoapObject request = new SoapObject(ws_Namespace,ws_Method);
for(ArryIndex = 0 ; ArryIndex < ParameterName.length ; ArryIndex ++)
{
PropertyInfo ParaObj = new PropertyInfo();
ParaObj.type = PropertyInfo.OBJECT_CLASS;
ParaObj.namespace = ws_Namespace;
ParaObj.setName(ParameterName[ArryIndex].toString());
ParaObj.setValue(ParameterValue[ArryIndex].toString());
request.addProperty(ParaObj);
}
System.setProperty("http.keepAlive", "false");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
//envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.setAddAdornments(true);
HttpTransportSE androidHttpTransport = new HttpTransportSE(ws_URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
androidHttpTransport.call(ws_SOAPAction, envelope);
androidHttpTransport.debug = true;
resultsRequestSOAP = (SoapObject) envelope.bodyIn;
答案 1 :(得分:0)
你应该创建一个实现kvmserializable接口的类
This is a tutorial for sending complex objects through ksoap2