我正在尝试向我的Web服务发送一个复杂的对象并返回一个字符串值但是我的logcat从android返回Null Refference
完整代码ksoap2发送对象
Questionnairekeyval qk = new Questionnairekeyval(5, 8, "Questionnaire1", "", "", "", "", "", "", "", "");
PropertyInfo pi = new PropertyInfo();
pi.setName("Questionnairekeyval");
pi.setValue(qk);
pi.setType(qk.getClass());
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
// 2. Set the request parameters
envelope.setOutputSoapObject(request);
envelope.addMapping(WS_NAMESPACE, "Questionnairekeyval",
new Questionnairekeyval().getClass());
// 3. Create a HTTP Transport object to send the web service request
HttpTransportSE httpTransport = new HttpTransportSE(WSDL_URL);
// httpTransport.debug = true; // allows capture of raw request/respose
// in
// Logcat
// 4. Make the web service invocation
httpTransport.call(SOAP_ACTION, envelope);
String result;
if (envelope.bodyIn instanceof SoapFault) { // SoapFault =
// FAILURE
SoapFault soapFault = (SoapFault) envelope.bodyIn;
throw new Exception(soapFault.getMessage());
} else {
// SoapObject = SUCCESS
SoapPrimitive soapObject = (SoapPrimitive) envelope.getResponse();
result = (soapObject).toString();
Log.wtf("result SOAPObject", result + " " + soapObject);
}
C#获取对象并返回一个字符串
[WebMethod]
public String putAnswers(Questionnairekeyval reponse)
{
int a = reponse.idClient;
return Convert.ToString(a);
}
答案 0 :(得分:0)
在java请求中解决了属性的名称问卷Keyval但是在webservice中是响应所以它基本上就是为什么它返回null的问题