传递参数数组中的JSON格式SOAP的Web服务? [英] passing Array of parameter in json format to SOAP web service?
本文介绍了传递参数数组中的JSON格式SOAP的Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要通过这个阵列参数对KSOAP web服务的机器人。这是我的SOAP动作。
<?XML版本=1.0编码=UTF-8&GT?;
<肥皂:信封的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/\">
<肥皂:身体与GT;
<的get_info的xmlns =http://tempuri.org/>
<条款和GT;
< tc_id>串LT; / tc_id>
< tc_name>串LT; / tc_name>
< st_id>串LT; / st_id>
< /条款和GT;
< /&的get_info GT;
< / SOAP:身体与GT;
< / SOAP:信封>
我试过这样的,但我没有得到来自服务器的响应
的Java
公共最后弦乐SOAP_ACTION =http://tempuri.org/get_info;
公共最后弦乐OPERATION_NAME =的get_info;
公共最后弦乐WSDL_TARGET_NAMESPACE =http://tempuri.org/;
公共最后弦乐SOAP_ADDRESS =http://192.168.0.116/Teachers/backend.asmx?op=get_info;
SoapObject请求= NULL,
objMessages = NULL;
对象响应=无效;
SoapSerializationEnvelope信封; 字符串结果= NULL; //方法名变量定义Web服务哪些函数将调用
公共字符串passdetails(字符串方法名){
SoapObject解析度=新SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME); res.addProperty(tc_id,11);
res.addProperty(tc_name,XXX);
res.addProperty(st_id,1); 的System.out.println(请求===+ RES);
SoapObject要求=新SoapObject(OPERATION_NAME,条款);
request.addProperty(条款,RES);
的System.out.println(条款===+请求); SoapSerializationEnvelope信封=新SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = TRUE; envelope.setOutputSoapObject(请求); HttpTransportSE httpTransport =新HttpTransportSE(SOAP_ADDRESS);
对象响应= TRUE;
尝试{
httpTransport.call(SOAP_ACTION,信封);
响应= envelope.getResponse();
串result123 = response.toString();
的System.out.println(result123 ==+ result123);
}赶上(例外的例外){
响应= exception.toString();
}
返回response.toString();
}
我不知道我错了。我搜索很多改编,但我不能找到一个妥善的解决办法。感谢adavance
解决方案
request.addProperty(IMGBA1);
request.addProperty(的uname,用户名);
request.addProperty(ALBUMNAME,人);
request.addProperty(imagename,唯一ID); //声明SOAP请求的版本 SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(请求); envelope.dotNet = TRUE; 尝试{ HttpTransportSE androidHttpTransport =新HttpTransportSE(URL); //这是一个将调用WebService的实际部件 androidHttpTransport.call(SOAP_ACTION,信封); //从信封身体SOA的presult。 SoapObject RESULT1 =(SoapObject)envelope.bodyIn; 如果(RESULT1!= NULL) {
alertbox(消息!,图片上载成功); } 其他 { alertbox(!消息,无Internet连接!); } }赶上(例外五){ e.printStackTrace(); }
I need to pass this Array of parameter to Ksoap webservice in android. This is my soap action.
<?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>
I Tried like this but i am not getting any response from server
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();
}
I dont know where i am wrong. i searched lot regrading this but i cant find a proper solution. thanks in adavance
解决方案
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();
}
这篇关于传递参数数组中的JSON格式SOAP的Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文