Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 17
Registered: ‎01-07-2010
My Device: Not Specified
Accepted Solution

web service parameter

[ Edited ]

Hi all,

 

these are my web services (vb). I'm able to call the first one from my widget, Hello world without input parameters. 

But how can I use the second web service? how can I set the name from my widget?

 

<WebMethod()>

Public Function HelloWorld() As String             

         Return "Hello World"

End Function

 

<WebMethod()>

Public Function HelloWorldNome(ByVal nome As String) As String

         Return "Hello World " & nome

             

End Function

 

 Thanks

 

 

 

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: web service parameter

Hi tangen,

 

To call a web service from your BlackBerry Widget, you can use the XmlHttpRequest object to make an HTTP request to your web service URL.  In order to pass parameters, you need to use the method type of "POST" in your web request.

 

Here's a code snippet on how to do this:

 

 

var params = 'nome=tagen';
req = new XMLHttpRequest();
req.open('POST', 'http://yourUrlHere.com/service.asmx', true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader('Content-length', params.length);
req.setRequestHeader('Connection', 'close');
req.onreadystatechange = yourCallBackMethod();
req.send(params);

 

Note the three request header parameters and their values, that must be set when sending a POST request using XHR.

 

For more information on using XmlHttpReuquest in your web content, please see knowledge base article DB-00765.

 

Sincerely,

Adam

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
New Developer
Posts: 17
Registered: ‎01-07-2010
My Device: Not Specified

Re: web service parameter

[ Edited ]

thank you!!!!!!!  I've changed something and everything works!!!

 

 

var params = 'nome=tagen';
req = new XMLHttpRequest();
req.onreadystatechange = yourCallBackMethod();

req.open('POST', 'http://yourUrlHere.com/service.asmx/HelloWorldNome', true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader('Content-length', params.length);
req.setRequestHeader('Connection', 'close');

req.send(params);

 

 

 

Luca

Highlighted
Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: web service parameter

Does this work for making SOAP calls in APS.Net/C# as well?

----------------------------------------------------------------------------
chown -R us ./base
~J!NX