Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i call a webservice using phonegap for android

How do I make a webservice call from my phonegap app? I found two javascript libraries one from IBM and another IvanWebService http://wiki.phonegap.com/w/page/43725416/SOAP%20Web%20Service that allow you to make such calls but i couldnt get them to run any of my webservices. I am passing in a wsdl link as the service link and i have updated the envelope parameters, still nothing.

like image 377
abs Avatar asked Sep 25 '11 01:09

abs


2 Answers

If it were me, I would use jQuery.

http://www.bennadel.com/blog/1853-Posting-XML-SOAP-Requests-With-jQuery.htm http://openlandscape.net/2009/09/25/call-soap-xm-web-services-with-jquery-ajax/ http://weblogs.asp.net/jan/archive/2009/04/09/calling-the-sharepoint-web-services-with-jquery.aspx

like image 159
Jason Dean Avatar answered Oct 23 '22 03:10

Jason Dean


<head>

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>

<script type="text/javascript">
        $(function() {

            $("#requestXML").click(function() {

                     $.ajax({
                      type: "POST",
                      url: "http://YOURSITE/script.php",
                      data: "{}",
                      cache: false,
                      dataType: "xml",
                      success: onSuccess
                    });

            });

            $("#resultLog").ajaxError(function(event, request, settings, exception) {
              $("#resultLog").html("Error Calling: " + settings.url + "<br />HTTP Code: " + request.status);
            });

             function onSuccess(data)
              {   alert(data);
               }


        });

        </script>

</head>

Button to call the above method:

<input id="requestXML" type="button" value="Request XML" />
like image 34
Vinayak Bevinakatti Avatar answered Oct 23 '22 03:10

Vinayak Bevinakatti