如何处理 SOAPPRIMITIVE 响应

发布于 2024-11-19 08:56:19 字数 2623 浏览 2 评论 0原文

我有返回 String 类型的 WCF 方法。

这是我的输出

{“表1”:[{“表名称”: “负载分配器”,“描述”: “经销商”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: "0"},{"表名": "加载价格","描述" : "价格 ","MandatoryFlag" : "1","状态" : "","优先级": "0"},{"表名": "加载产品","描述" : "产品 ","MandatoryFlag" : "1","状态" : "","优先级": "0"},{"表名": “加载交易方案详细信息”,“描述” :“TradeSchemeDeta”,“MandatoryFlag”: “1”,“状态”:“”,“优先级”: "0"},{"表名": “RD.AlternativeProductDetail”,“描述” :“AltProdutDetail”,“MandatoryFlag”: “0”,“状态”:“”,“优先级”: "0"},{"表名": “RD.AlternativeProductHeader”,“描述” :“AltProdutHeader”,“MandatoryFlag”: “0”,“状态”:“”,“优先级”: "0"},{"表名": "RD.BatchPriceDetail","描述" : “批量价格”,“强制标志”: “1”,“状态”:“”,“优先级”: "0"},{"表名": “RD.执行”,“描述”: “执行”,“强制标志”: “1”,“状态”:“”,“优先级”: "0"},{"表名": "RD.Route","Description" : "路线 ","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"}]}

这是我的 Soap 处理方法

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

如何仅获取列表或数组中的表名称。 请帮助我。这里出了什么问题?

I have WCF method that return String type.

This is my output

{"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"}]}

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;
 }

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜血染红嫁衣 2024-11-26 08:56:19

您了解 SOAP 和 JSON 之间的区别吗? kSOAP 用于处理期望 SOAP 请求并返回 SOAP 响应的服务。因此,除非您有 SOAP 服务返回带有 JSON 的单个字符串元素,否则您不需要(也不能使用)kSoap。如果您有返回 JSON 的 REST 服务,请使用简单的 DefaultHttpClientHttpPost 作为 此处举例说明。如果您一直使用 JSON,它也会回答您的上一个问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文