Re: [android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hi, Sorry for being late I was away for a while. I hope your problem is solved, if not, then I think the problem might be easy to fix since the code looks normal to me. There is an option on the server side that might casuing the problem. If you use Internet explorer, you need to rnale the option Access data sources across domains, if not then the windows will not allow Android to pass data to the web services. Let me know if that helps, Good luck On Tue, Jan 19, 2010 at 2:47 PM, fischchris fischch...@gmail.com wrote: Hello, I too am having this problem with a .net web service and am curious if anyone can just look at my code and give some advice. I've followed the suggestions thus far and either way I try it I'm getting the same thing. I have a feeling it's something simple but I just can't figure it out. Below is my code which is probably similar to every one elses doing this: I only pasted the parts that actually mean something to this question. In my webservice method, I've changed Num from int to string, when it was an int, the service would return a 0, even though I passed in1. When it's a string, it returns an empty string. Again like others who have posted, I can call a method with no parameters just fine, but that doesn't help me much. Any other advice anyone can offer would be super appreciated. I'm running out of ideas of things to try. Thank you all for the posts so far. Cheers! 1) Client code on android: //Web Service Variables private static final String NAMESPACE = https://chris1.m2mops.com ; private static final String URL = https://chris1.m2mops.com/ snowreportdata/snowreportdata.asmx; private static final String SOAP_ACTION = https://chris1.m2mops.com/ TestWithParams; private static final String METHOD = TestWithParams; public String GetTestData() { SoapObject request = new SoapObject(NAMESPACE, METHOD); //How to add variables to your web service call. request.addProperty(Num,1); //PropertyInfo pi = new PropertyInfo(); //pi.setName(Num); //pi.setValue(1); //request.addProperty(pi); //Integer PropertyCount = request.getPropertyCount(); //gets the property count for the WS. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); //HttpTransportSE androidHttpTransport = new HttpTransportSE (URL); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); try{ androidHttpTransport.call(SOAP_ACTION, envelope); java.lang.Object Test = (java.lang.Object)envelope.getResponse (); //return ( + PropertyCount.toString() + ) + Test.toString(); return Test.toString(); }catch(Exception e){ return ERROR: + e.getMessage(); } } 2) Web service code: [WebService(Namespace = https://chris1.m2mops.com/;)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [WebMethod(Description = Testing method with parameters being passed in)] public string TestWithParams(string Num) { return Testing from WS, Value Rcvd was: + Num; } On Dec 19 2009, 7:07 am, android09 pranav.jaja...@gmail.com wrote: Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com
[android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hello, I too am having this problem with a .net web service and am curious if anyone can just look at my code and give some advice. I've followed the suggestions thus far and either way I try it I'm getting the same thing. I have a feeling it's something simple but I just can't figure it out. Below is my code which is probably similar to every one elses doing this: I only pasted the parts that actually mean something to this question. In my webservice method, I've changed Num from int to string, when it was an int, the service would return a 0, even though I passed in1. When it's a string, it returns an empty string. Again like others who have posted, I can call a method with no parameters just fine, but that doesn't help me much. Any other advice anyone can offer would be super appreciated. I'm running out of ideas of things to try. Thank you all for the posts so far. Cheers! 1) Client code on android: //Web Service Variables private static final String NAMESPACE = https://chris1.m2mops.com;; private static final String URL = https://chris1.m2mops.com/ snowreportdata/snowreportdata.asmx; private static final String SOAP_ACTION = https://chris1.m2mops.com/ TestWithParams; private static final String METHOD = TestWithParams; public String GetTestData() { SoapObject request = new SoapObject(NAMESPACE, METHOD); //How to add variables to your web service call. request.addProperty(Num,1); //PropertyInfo pi = new PropertyInfo(); //pi.setName(Num); //pi.setValue(1); //request.addProperty(pi); //Integer PropertyCount = request.getPropertyCount(); //gets the property count for the WS. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); //HttpTransportSE androidHttpTransport = new HttpTransportSE (URL); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); try{ androidHttpTransport.call(SOAP_ACTION, envelope); java.lang.Object Test = (java.lang.Object)envelope.getResponse (); //return ( + PropertyCount.toString() + ) + Test.toString(); return Test.toString(); }catch(Exception e){ return ERROR: + e.getMessage(); } } 2) Web service code: [WebService(Namespace = https://chris1.m2mops.com/;)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [WebMethod(Description = Testing method with parameters being passed in)] public string TestWithParams(string Num) { return Testing from WS, Value Rcvd was: + Num; } On Dec 19 2009, 7:07 am, android09 pranav.jaja...@gmail.com wrote: Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hi, In the server side (the web services), change the namespace, by default the name space is http://tempuri.org, change that to any conveient name you like. That will solve the problem unless there is something else wrong. Good luck :) On Mon, Jan 4, 2010 at 2:11 AM, tharindu tharindu.r...@gmail.com wrote: Hi, Im having the same problem as yours. You have mentioned using http://tempuri.org is wrong. Can you please explain what u did to solve the problem. What is the correct namespace then?? Please help me on this. Im stucked on this. :( Thanx in advance.. On Dec 20 2009, 10:59 pm, fadi wedyan wedi...@gmail.com wrote: Hi, Thanks for your answer, I had solved the problem last night. I agree with that these steps are important. But there is also two other steps on the server side that I was not aware of, I think you had them set correctly (becouse your code is working). Beside following the steps you mentioned, we also need to change the namespace of the web services, usinghttp://tempuri.orgis wrong. Also, there is an option in the IE explorer that needs to be checked. The option allow access data source accros domains needs to be checked. Also, in order to pass data other than strings (float, integers,...), we need to implement a serliziation class for these data types and compile it with the library. Thanks for your kind reply, this was really a big headache! On Sat, Dec 19, 2009 at 7:07 AM, android09 pranav.jaja...@gmail.com wrote: Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hi, Im having the same problem as yours. You have mentioned using http://tempuri.org is wrong. Can you please explain what u did to solve the problem. What is the correct namespace then?? Please help me on this. Im stucked on this. :( Thanx in advance.. On Dec 20 2009, 10:59 pm, fadi wedyan wedi...@gmail.com wrote: Hi, Thanks for your answer, I had solved the problem last night. I agree with that these steps are important. But there is also two other steps on the server side that I was not aware of, I think you had them set correctly (becouse your code is working). Beside following the steps you mentioned, we also need to change the namespace of the web services, usinghttp://tempuri.orgis wrong. Also, there is an option in the IE explorer that needs to be checked. The option allow access data source accros domains needs to be checked. Also, in order to pass data other than strings (float, integers,...), we need to implement a serliziation class for these data types and compile it with the library. Thanks for your kind reply, this was really a big headache! On Sat, Dec 19, 2009 at 7:07 AM, android09 pranav.jaja...@gmail.com wrote: Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hi, Thanks for your answer, I had solved the problem last night. I agree with that these steps are important. But there is also two other steps on the server side that I was not aware of, I think you had them set correctly (becouse your code is working). Beside following the steps you mentioned, we also need to change the namespace of the web services, using http://tempuri.org is wrong. Also, there is an option in the IE explorer that needs to be checked. The option allow access data source accros domains needs to be checked. Also, in order to pass data other than strings (float, integers,...), we need to implement a serliziation class for these data types and compile it with the library. Thanks for your kind reply, this was really a big headache! On Sat, Dec 19, 2009 at 7:07 AM, android09 pranav.jaja...@gmail.com wrote: Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
Hi wedyan, I had also the same problem but finally i got the solution. I have some steps for you, just go through it. 1) Remove PropertyInfo from your code and add this like: SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP); // if you have 2 params in .net than add property this way. Suppose, sum of two integers instead of PropertyInfo request.addProperty(num, str1); request.addProperty(b, str2); 2) Use HttpTransportSE instead of AndroidHttpTransport. and add androidHttpTransport.setXmlVersionTag(?xml version=\1.0\ encoding= \UTF-8\?); 3) To Display Result: SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse (); System.out.println(resultString); txtView.setText(Result is : +resultString); Now, go through the above steps and also compare your application. I hope you will find the solution. Let's hope. Best Luck -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en