BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Need help in Calling webservice using Ksoap (http://www.blackberryforums.com/developer-forum/78404-need-help-calling-webservice-using-ksoap.html)

yashovardhan 05-29-2007 04:47 AM

Need help in Calling webservice using Ksoap
 
Hello all,
I am developing a standalone application for calling webservice from blackberry. I am using ksoap-1.2 and blackberry JDE 4.0.2. Webservice is written in .NET.
My webservice client code looks like this:

Object response=null;
HttpTransport ht = new HttpTransport("http://www.webservicex.net/country.asmx","\"http://www.webserviceX.NET/GetCurrencyByCountry\""); SoapObject request = new SoapObject("http://www.webservicex.net/","GetCurrencyByCountry");
request.addProperty("CountryName","india"); response=ht.call(request);
System.out.println("Webservice response " + response.toString())

I get the following exception:
soap falut-soap:Server faultstring: System.Web.Services.Protocols.SoapException:Server was unable
to process request--->System.Data.SqlClient.SqlException:Procedure or function getCurrencyByCountry expects
parameter '@name' which was not supplied at WebServicex.country.GetCurrencyByCountry(String CountryName)---
End of inner exception stack trace--'faultactor:'null' detaild:[EndTag </detail>]]

The exception tells that the required parameter is not passed.
But i am passing the parameter in the above code like this:

request.addProperty("CountryName","india");

u can also check the webservice in the path mentioned in above code

Any help regarding this will be appreciated.

thanks in advance.

jfisher 05-29-2007 06:15 AM

looks to me like your http request is completely seperate from the soap object. try something like this instead:

class testSoap extends Thread{

String url = "";
String serverResponse = "";

public void run() {
try {
SoapObject RPC = new SoapObject("http://webservices.mycompany.net/module", "webservicename");
RPC.addProperty("parameterName", "");
serverResponse = "" + new HttpTransport(url, "http://webservices.mycompany.net/module/webservicename").call(RPC);
}catch (SoapFault sf){

}catch(Exception e){

}
System.out.println("serverResponse = " + serverResponse);
}

yashovardhan 05-29-2007 07:35 AM

hi jfisher,
the problem is not with the wrong http request.It is correct because i am able to hit the webservices.In the exception it clearly says that:
System.Data.SqlClient.SqlException:Procedure or function getCurrencyByCountry expects parameter '@name' which was not supplied at WebServicex.country.GetCurrencyByCountry(String CountryName)

SoapAction value i have taken from wsdl.so it is correct

i think i am passing parameter wrongly..do u have any other idea of passing the parameter.

jfisher 05-29-2007 07:48 AM

oh aye, missed the ht.call(request); cos there's no line break. your soap property looks fine so it may be an issue with the namespace, i'm assuming something weird happened when you pasted your code, this:

HttpTransport("http://www.webservicex.net/country.asmx","\"http://www.webserviceX.NET/GetCurrencyByCountry\"");

looks very wrong.

yashovardhan 05-30-2007 08:02 AM

hi jfisher,

i am unable to pass the the paramter. i even tested by putting break point in my .net application and tried calling webservice.the request came there but with no parameter eventhough i am passing parameter like this in j2me client:

request.addProperty("parameter name","parameter value");

actually i am passing string value and returning boolean. so i dont need any SoapPrimitive object here because i am passing string.

so i am wrong in passing parameter.please help me to overcome this.
Suggest the correct way to pass the parameter.

luisrogero 06-05-2007 10:42 AM

hello, im from argentina.
I'm new in BB development, I need a simple complete example to consume a web service from one BlackBerry with BB JDE 1.4...


Thank You

Luis Rogero

luisrogero 06-05-2007 10:57 AM

consume a web service from one BlackBerry with BB JDE 1.4..
 
hello, im from argentina.
I'm new in BB development, I need a simple complete example as consume a web service from one BlackBerry with BB JDE 1.4...


Thank You

Luis Rogero


All times are GMT -5. The time now is 06:25 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.