我需要将这个参数数组传递给android中的Ksoap webservice。这是我的肥皂行动。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<get_info xmlns="http://tempuri.org/">
<terms>
<tc_id>string</tc_id>
<tc_name>string</tc_name>
<st_id>string</st_id>
</terms>
</get_info>
</soap:Body>
</soap:Envelope>
我试过这样但我没有收到服务器的任何回复
的java
public final String SOAP_ACTION = "http://tempuri.org/get_info";
public final String OPERATION_NAME = "get_info";
public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
public final String SOAP_ADDRESS ="http://192.168.0.116/Teachers/backend.asmx?op=get_info";
SoapObject request = null,
objMessages = null;
Object response = null;
SoapSerializationEnvelope envelope;
String result = null;
// MethodName variable is define for which webservice function will call
public String passdetails(String MethodName) {
SoapObject res = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
res.addProperty("tc_id","11");
res.addProperty("tc_name","xxx");
res.addProperty("st_id","1");
System.out.println("request==="+res);
SoapObject request = new SoapObject(OPERATION_NAME,"terms");
request.addProperty("terms",res);
System.out.println("terms==="+request);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response = true;
try {
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
String result123=response.toString();
System.out.println("result123=="+result123);
} catch (Exception exception) {
response = exception.toString();
}
return response.toString();
}
我不知道我哪里错了。我搜索了很多重新审查这个,但我找不到一个合适的解决方案。谢谢你的意见
答案 0 :(得分:0)
request.addProperty("img",ba1);
request.addProperty("uname",username);
request.addProperty("albumname",al);
request.addProperty("imagename",uniqueID);
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
SoapObject result1 = (SoapObject)envelope.bodyIn;
if(result1 != null)
{
alertbox("Message!", "Image Uploaded successfully");
}
else
{
alertbox("Message!", "No Internet Connection!");
}
} catch (Exception e) {
e.printStackTrace();
}