如何处理SOAPPRIMITIVE响应

编程入门 行业动态 更新时间:2024-10-11 03:26:04
本文介绍了如何处理SOAPPRIMITIVE响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有WCF方法返回字符串类型。

I have WCF method that return String type.

这是我的输出

{表1:[{表名:  LoadDistributor,说明:  分销商,MandatoryFlag:  1,状态:,优先级:  0},{表名:  LoadPrice,说明:价格  ,MandatoryFlag:1,状态:  ,优先级:0},{表名:  LoadProduct,说明:产品  ,MandatoryFlag:1,状态:  ,优先级:0},{表名:  LoadTradeSchemeDetail,说明  :TradeSchemeDeta,MandatoryFlag:  1,状态:,优先级:  0},{表名:  RD.AlternativeProductDetail,说明  :AltProdutDetail,MandatoryFlag:  0,状态:,优先级:  0},{表名:  RD.AlternativeProductHeader,说明  :AltProdutHeader,MandatoryFlag:  0,状态:,优先级:  0},{表名:  RD.BatchPriceDetail,说明:  BatchPrice,MandatoryFlag:  1,状态:,优先级:  0},{表名:  RD.Executive,说明:  行政,MandatoryFlag:  1,状态:,优先级:  0},{表名:  RD.Route,说明:路线  ,MandatoryFlag:1,状态:  ,优先级:0},{表名:  RD.vwRetailer,说明:  零售商,MandatoryFlag:  1,状态:,优先级:  0},{表名:  RD.vwRouteDetail,说明:  RouteDetail,MandatoryFlag:  1,状态:,优先级:  0},{表名:  XA.vwProductType,说明:  品牌产品C,MandatoryFlag:  1,状态:,优先级:  0},{表名:  XA.vwTown,说明:城  ,MandatoryFlag:1,状态:  ,优先:0}]}

{"Table1" : [{"TableName" : "LoadDistributor","Description" : "Distributor ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "LoadPrice","Description" : "Price ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "LoadProduct","Description" : "Product ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "LoadTradeSchemeDetail","Description" : "TradeSchemeDeta","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "RD.AlternativeProductDetail","Description" : "AltProdutDetail","MandatoryFlag" : "0","Status" : "","Priority" : "0"},{"TableName" : "RD.AlternativeProductHeader","Description" : "AltProdutHeader","MandatoryFlag" : "0","Status" : "","Priority" : "0"},{"TableName" : "RD.BatchPriceDetail","Description" : "BatchPrice ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "RD.Executive","Description" : "Executive ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "RD.Route","Description" : "Route ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "RD.vwRetailer","Description" : "Retailer ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "RD.vwRouteDetail","Description" : "RouteDetail ","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "XA.vwProductType","Description" : "Brand Product C","MandatoryFlag" : "1","Status" : "","Priority" : "0"},{"TableName" : "XA.vwTown","Description" : "Town ","MandatoryFlag" : "1","Status" : "","Priority" : "0"}]}

这是我的SOAP处理方法

This is my Soap processing method

// 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(作为一个字符串)。

My C# method return String with JSON( as a String).

如何只在列表或数组中获得的表名。请帮我。什么是错在这里?

How to get the Table name only in the List or Array. Please help me .What is wrong here?

推荐答案

你了解SOAP和JSON的区别? KSOAP是加工服务期待SOAP请求并返回SOAP响应。所以,除非你有SOAP服务使用JSON返回一个字符串元素你不需要(且不能使用)KSOAP。如果你有REST服务返回的JSON使用简单的 DefaultHttpClient 和 HttpPost 为described这里例子。如果您正在使用JSON所有的时间也回答您的$p$pvious问题。

Do you understand the difference between SOAP and JSON? kSOAP is for processing services expecting SOAP request and returning SOAP response. So unless you have SOAP service returning single string element with JSON you don't need (and cannot use) kSoap. If you have REST service returning JSON use simple DefaultHttpClient and HttpPost as described for example here. If you are using JSON all the time it also answers your previous question.

更多推荐

如何处理SOAPPRIMITIVE响应

本文发布于:2023-11-25 23:27:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631774.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何处理   SOAPPRIMITIVE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!