1

在我的一个应用程序中,我想向ObjectWCF 服务发送一个。这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 服务中,我的同事将此对象转换为他的舒适对象,然后将其提取。所以我想绑定。有可能吗朋友。如果可能的话,请指导我。

提前致谢。

4

2 回答 2

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;
于 2013-08-01T10:59:25.187 回答
0

你应该创建一个实现 kvmserializable 接口的类

这是通过ksoap2发送复杂对象的教程

于 2013-08-14T18:09:01.653 回答