コード例 #1
0
    protected String doInBackground(String... arguments) {
      try {
        // request parameters
        String productId = arguments[0];
        // soap login to get session id
        HttpTransportSE ht = getHttpTransportSE();
        if (configShared.getString("SESSION_ID", "5").equalsIgnoreCase("Session_Not_Loggin")) {
          String session_id = SplashScreen.sessionObj.getSessionId(ht, configShared);
          Singleton.getInstance().setSessionId(session_id);
          editor.putString("SESSION_ID", "noSessionId");
          editor.commit();
        }

        // request for customer login
        SoapObject customerLoginRequest = new SoapObject(NAMESPACE, "mobikulCatalogAddtoWishlist");
        SoapSerializationEnvelope requestEnvelop =
            getSoapSerializationEnvelope(customerLoginRequest);
        customerLoginRequest.addProperty("sessionId", Singleton.sessionId);
        JSONObject jo = new JSONObject();
        SharedPreferences customerDataShared =
            mContext.getSharedPreferences("customerData", Context.MODE_PRIVATE);
        Log.d("some", customerDataShared.getString("customerId", ""));
        jo.put("storeId", configShared.getString("storeId", "1"));
        jo.put("productId", productId);
        jo.put("customerId", customerDataShared.getString("customerId", ""));

        String jsonAsString = jo.toString();

        PropertyInfo stringArrayPropertyInfo = new PropertyInfo();
        stringArrayPropertyInfo.setName("attributes");
        stringArrayPropertyInfo.setValue(jsonAsString);
        stringArrayPropertyInfo.setType(jsonAsString.getClass());
        customerLoginRequest.addProperty(stringArrayPropertyInfo);

        while (true) {
          try {
            ht.call(NAMESPACE, requestEnvelop);
            break;
          } catch (IOException ex) {
            Log.d("create account ", "Io exception bufferedIOStream closed" + ex);
          }
        }
        Log.d("aayaya", "adsdfd");

        try {
          customerLoginResponse = (Object) requestEnvelop.getResponse();
        } catch (SoapFault e) {
          Log.d("Exception sessionId", e.getMessage());
          editor = configShared.edit();
          editor.putString("SESSION_ID", "Session_Not_Loggin");
          editor.commit();
          (new Connection3()).execute();
          this.cancel(true);
          return "no";
        }

        String customerLoginResponseAsString = customerLoginResponse.toString();
        Log.d("Some", customerLoginResponseAsString);
        newsLetterObject = new JSONObject(customerLoginResponseAsString);
        return "yes";
      } catch (Exception e) {
        Log.d("Exception", e.toString());
        return "no";
      }
    }
コード例 #2
0
    @Override
    protected String doInBackground(String... arguments) {
      try {
        // soap login to get session id
        HttpTransportSE ht = new HttpTransportSE(URL, 60000);
        ht.debug = true;
        ht.setXmlVersionTag("<!--?xml version=\"1.0\" encoding= \"UTF-8\" ?-->");
        if (configShared.getString("SESSION_ID", "5").equalsIgnoreCase("Session_Not_Loggin")) {
          String session_id = SplashScreen.sessionObj.getSessionId(ht, configShared);
          Singleton.getInstance().setSessionId(session_id);
          editor.putString("SESSION_ID", "noSessionId");
          editor.commit();
        }

        JSONObject jo = new JSONObject();
        SoapObject soapRequest = null;
        if (!searchQuery.isEmpty()) {
          soapRequest = new SoapObject(NAMESPACE, "mobikulCatalogGetcatalogsearchResult");
          jo.put("searchQuery", searchQuery);
          Log.d("CASE CONN CALLED", "1");
        } else if (queryStringJSON != null) {
          soapRequest = new SoapObject(NAMESPACE, "mobikulCatalogGetadvancedsearchResult");
          jo.put("queryString", queryStringJSON.toString());
          Log.d("CASE CONN CALLED", "2");
        } else {
          soapRequest = new SoapObject("urn:Magento", "mobikulCatalogGetcategoryproductList");
          jo.put("categoryId", categoryId);
          jo.put("filterData", filterData);
          Log.d("CASE CONN CALLED", "3");
        }

        SoapSerializationEnvelope requestEnvelop =
            new SoapSerializationEnvelope(SoapEnvelope.VER11);
        requestEnvelop.dotNet = false;
        requestEnvelop.xsd = SoapSerializationEnvelope.XSD;
        requestEnvelop.enc = SoapSerializationEnvelope.ENC;
        requestEnvelop.setOutputSoapObject(soapRequest);

        soapRequest.addProperty("sessionId", Singleton.sessionId);
        jo.put("storeId", configShared.getString("storeId", "1"));
        jo.put("sortData", selectedSortData);
        jo.put("width", screen_width);
        jo.put("pageNumber", pageNumber);
        String jsonAsString = jo.toString();
        Log.d("DEBUG", jsonAsString);

        PropertyInfo stringArrayPropertyInfo = new PropertyInfo();
        stringArrayPropertyInfo.setName("attributes");
        stringArrayPropertyInfo.setValue(jsonAsString);
        stringArrayPropertyInfo.setType(jsonAsString.getClass());
        soapRequest.addProperty(stringArrayPropertyInfo);
        while (true) {
          try {
            ht.call(NAMESPACE, requestEnvelop);
            break;
          } catch (IOException ex) {
            ex.printStackTrace();
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
        try {
          mainResponse = (Object) requestEnvelop.getResponse();
        } catch (SoapFault e) {
          e.printStackTrace();
          editor = configShared.edit();
          editor.putString("SESSION_ID", "Session_Not_Loggin");
          editor.commit();
          (new GetCategoryPageDataConnection()).execute();
          this.cancel(true);
          return "no";
        }
        String mainResponseAsString = mainResponse.toString();
        mainObject = new JSONObject(mainResponseAsString);
        return "yes";
      } catch (Exception e) {
        e.printStackTrace();
        return "no";
      }
    }