0

I'm using an android app which uses ASP.net web service but I get " Server did not recognize the value of HTTP header " error in placeKOT() method in android studio .I'm using Ksoap library to communicate with ASP.net webservice .

Web Service code

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[WebMethod]
    public string placeOrder(string _order)
    {
        try
        {
            Database db = DatabaseFactory.CreateDatabase("TransportCon");
            DataSet rtnDataSet = new DataSet();
            string strQuery = ConnectionClass.placeKOT;


            DbCommand dbCommand = db.GetStoredProcCommand(strQuery);
            dbCommand.CommandTimeout = 0;



            rtnDataSet = db.ExecuteDataSet(dbCommand);

            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
            Dictionary<string, object> row;
            Dictionary<string, object> row1;
            int count = 0;
            foreach (DataRow dr in rtnDataSet.Tables[0].Rows)
            {
                row = new Dictionary<string, object>();
                row1 = new Dictionary<string, object>();
                foreach (DataColumn col in rtnDataSet.Tables[0].Columns)
                {
                    row.Add(col.ColumnName, dr[col]);
                    // row.Add(count++, row1);
                }
                rows.Add(row);

            }

            rtnDataSet.AcceptChanges();
            string json = JsonConvert.SerializeObject(rtnDataSet, Formatting.Indented);
            return json;


        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

Android App web service call

 private static final String PLACE_ORDER = "http://tempuri.org/placeOrder";

    private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

 private static final String placeOrder = "placeOrder";
 private static final String SOAP_ADDRESS = "http://10.0.2.2/WebSite1/Service.asmx";

   public boolean placeKOT(String item,ArrayList<Items> items){
        try {
            JSONObject obj = AddItemsToKotTable(item, items);

            SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,placeOrder);


            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            // request.addProperty("_touchCode", touchCode);
            //Restaurants selectedRES=(Restaurants)selectedItem;

            request.addProperty("_order",obj.toString() );


            HttpTransportSE androidHttpTransport = new HttpTransportSE(SOAP_ADDRESS);
            androidHttpTransport.debug = true;
            String results = null;

            try {
                androidHttpTransport.call(PLACE_ORDER, envelope);

                SoapPrimitive result = (SoapPrimitive) envelope.getResponse();

                results = result.toString();

                if(results=="true")
                return true;
                else
                    return false;
            }
            catch (Exception e){
                return  false;
            }
        }
        catch(Exception e) {
            return false;
        }
    }

After this line

 androidHttpTransport.call(PLACE_ORDER, envelope);

it raises that exception and doesn't hit the break point in Visual studio

I have few more webmethods passing a String that work fine what is the problem with this one in particular?

saurabh64
  • 363
  • 1
  • 4
  • 24
  • http://stackoverflow.com/questions/13599013/is-it-possible-to-call-wshttpbinding-from-android if it is ksaop2(wshttp binding) or else http://stackoverflow.com/a/14563386/1835764 – Nirmal Mar 27 '15 at 09:28
  • @Nirmal I have working webmethods only this one doesn't work and I dont know why – saurabh64 Mar 27 '15 at 09:38

0 Answers0