我有返回String类型的WCF方法。
这是我的输出
{“Table1”:[{“TableName”: “LoadDistributor”,“描述”: “Distributor”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “LoadPrice”,“描述”:“价格 “,”MandatoryFlag“:”1“,”状态“: “”,“优先级”:“0”},{“TableName”: “LoadProduct”,“Description”:“产品 “,”MandatoryFlag“:”1“,”状态“: “”,“优先级”:“0”},{“TableName”: “LoadTradeSchemeDetail”, “说明” :“TradeSchemeDeta”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.AlternativeProductDetail”, “说明” :“AltProdutDetail”,“MandatoryFlag”: “0”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.AlternativeProductHeader”, “说明” :“AltProdutHeader”,“MandatoryFlag”: “0”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.BatchPriceDetail”,“描述”: “BatchPrice”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.Executive”,“描述”: “执行”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.Route”,“描述”:“路线 “,”MandatoryFlag“:”1“,”状态“: “”,“优先级”:“0”},{“TableName”: “RD.vwRetailer”,“描述”: “零售商”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “RD.vwRouteDetail”,“描述”: “RouteDetail”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “XA.vwProductType”,“描述”: “品牌产品C”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: “0”},{“TableName”: “XA.vwTown”,“描述”:“城镇 “,”MandatoryFlag“:”1“,”状态“: “”,“优先级”:“0”}}}
这是我的肥皂加工方法
// ksoap2 calling wcf
public SoapPrimitive soapPrimitive(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException {
SoapPrimitive responses = null;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up request
request.addProperty("strExec", "7067");
request.addProperty("strBusinessUnit", "HEMA");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //put all required data into a soap envelope
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.debug = true;
try{
Log.w("Log_cat" ,"*********" + envelope.toString());
httpTransport.call(SOAP_ACTION, envelope);
Log.w("log_tag", " ===========" +SOAP_ACTION );
// Object result = (Object)envelope.getResponse();
// JSONArray jArray = new JSONArray(result.toString());
// Log.w("log_tag", " ===*********==" +jArray );
responses = (SoapPrimitive)envelope.getResponse();
}
catch(Exception e)
{
e.printStackTrace();
}
// Object response= envelope.getResponse();
return responses;
}
我的C#方法返回带有JSON的字符串(作为字符串)。
如何仅在列表或数组中获取表名。 请帮帮我。这里有什么问题?
答案 0 :(得分:3)
您了解SOAP和JSON之间的区别吗? kSOAP用于处理期望SOAP请求和返回SOAP响应的服务。因此,除非您使用JSON返回单个字符串元素的SOAP服务,否则您不需要(也不能使用)kSoap。如果您有REST服务返回JSON,请使用简单DefaultHttpClient
和HttpPost
作为described for example here。如果您一直在使用JSON,它也会回复您的previous question。