- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I create a web service and I want to call its from my file.js. How can I do it? When I press an enter button the webservice is run again(and take my parameter that for web service like user name and password). Actually I want to send parameter to my web service in the same time. Is it possible? If yes, How can I do it? I search on th enternet but cannot find an answer for my question.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1.) How did you build your application? (App Designer or did you hand code your project)
2.) What is the web service you are trying connect to? (Facebook, twitter, own server, etc.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you made the service data binding with the Web Services control, then the name you gave the service is a function ready to call. It is in the intel.xdk.services namespace.
For example:
intel.xdk.services.MarkitOnDemandQuote()
This will call the service, which returns a promise for its data. There is also an event with the same name as the service posted to the document.
Penultimately, if you have custom arguments, just pass them in an options. For example:
//get the result via a promise intel.xdk.services.MarkitOnDemandQuote({symbol:"INTC"}) .then(function(data){ console.log("here is the data from the service", data); }) //or get the result via na event $(document).on("intel.xdk.services.MarkitOnDemandQuote", function(evt, data){ console.log("event received. here is the data", data); }) intel.xdk.services.MarkitOnDemandQuote({symbol:"AAPL"); //will trigger the event
Lastly, if you want to _modify_ the data before any consumer sees it, you can pass in an xdkFilter: argument to the options. It is a function that will receive the raw data, and whatever it returns will be the data that is passed out through the promise or the event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, follow a simple example how to call a WebService... you can put it on your own javascript file, reference it on your HTML5 code and call this function:
function CallWebService() { $.ajax('http://YourWebServiceLink', { contentType: 'text/xml; charset=utf-8', dataType: 'xml', crossDomain: true, data: { pUserName : 'YourUserName', pPassWord : 'YourPassword' }, success: function(data) { var vSomeColumn01 = $(this).find("SomeColumn01").text(); var vSomeColumn02 = $(this).find("SomeColumn02").text(); var vSomeColumn03 = $(this).find("SomeColumn03").text(); var vSomeColumn04 = $(this).find("SomeColumn04").text(); }); }, error: function (data) { alert($(data).text); } }); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CHRIS P. (Intel) wrote:
If you made the service data binding with the Web Services control, then the name you gave the service is a function ready to call. It is in the intel.xdk.services namespace.
For example:
intel.xdk.services.MarkitOnDemandQuote()
This will call the service, which returns a promise for its data. There is also an event with the same name as the service posted to the document.
Penultimately, if you have custom arguments, just pass them in an options. For example:
//get the result via a promise intel.xdk.services.MarkitOnDemandQuote({symbol:"INTC"}) .then(function(data){ console.log("here is the data from the service", data); }) //or get the result via na event $(document).on("intel.xdk.services.MarkitOnDemandQuote", function(evt, data){ console.log("event received. here is the data", data); }) intel.xdk.services.MarkitOnDemandQuote({symbol:"AAPL"); //will trigger the eventLastly, if you want to _modify_ the data before any consumer sees it, you can pass in an xdkFilter: argument to the options. It is a function that will receive the raw data, and whatever it returns will be the data that is passed out through the promise or the event.
Firstly thank you for your answer. As I understand, you send to me two piece of code that I can use in my project and I can choose one of them, isn't it? and I have a few questions:
1) What is the mean of "INTC" at "...intel.xdk.services.MarkitOnDemandQuote({symbol:"INTC"})..." ? What can I put instead of INTC? "symbol" is a variable or not? If yes what can I put instead of it? (and mean of "AAPL"?)
2)
.then( function (data){ |
04 |
console.log( "here is the data from the service" , data); |
05 |
}) |
this function is my web services function, isn't it? and "data" is my returning value? If I want to send two parameter I must do like follow?
.then( function (userName, password,data){ |
04 |
console.log( "here is the data from the service" , data); |
05 |
}) |
Thank you...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rodrigo M. wrote:
Hello, follow a simple example how to call a WebService... you can put it on your own javascript file, reference it on your HTML5 code and call this function:
function CallWebService() { $.ajax('http://YourWebServiceLink', { contentType: 'text/xml; charset=utf-8', dataType: 'xml', crossDomain: true, data: { pUserName : 'YourUserName', pPassWord : 'YourPassword' }, success: function(data) { var vRecID = $(this).find("SomeColumn01").text(); var vMake = $(this).find("SomeColumn02").text(); var vModel = $(this).find("SomeColumn03").text(); var vYear = $(this).find("SomeColumn04").text(); }); }, error: function (data) { alert($(data).text); } }); }
thank you but I don't want to reach my services with url. I want to reach it with web services that I created in intel xdk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brandon Kiefer (Intel) wrote:
1.) How did you build your application? (App Designer or did you hand code your project)
2.) What is the web service you are trying connect to? (Facebook, twitter, own server, etc.)
1) I built my application with app designer and hand code. I firstly built it with app designer and then I built with hand code somewhere that I cannot do it with app designer.
2)I try to connect with I created new services. it is business' web site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The other words my problem is like that: <script> function Control(){ var MINLENGTH = 3; var formUsername = document.forms.login.e_posta.value; var formPassword = document.forms.login.password.value; //is that true?????????????????????????????????? intel.xdk.services.LNLAyatar3Bolge({symbol:"INTC"}) .then(function(data){ console.log("here is the data from the service", data); alert(data); alert("cefdvefv"); }) return; } </script>
My piece of code is upside. I take the username(formUsername) and user password(formPasword) from user. And then I click the my ENTER button. When I click the ENTER button I call this script code. I want to this code run like that Call the my web services and send the formUsername annd fromPassword to web service(or my web service's data binding).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my example, {symbol:"INTC"} is data that a specific service was looking for. It was just example data.
Think of it as {search:"puppies"} for an image searching service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you look at your web service in App Designer (in the "Service Methods" pane, you'll see there are two description panes for it: "Request" an d "Response". Request the parameters your service expects.
So you can use _those_ instead of "symbol". Let's pretend one parameter is "user" and the other "password". Then your code would look like this:
function Control(){ var MINLENGTH = 3; var formUsername = document.forms.login.e_posta.value; var formPassword = document.forms.login.password.value; intel.xdk.services.LNLAyatar3Bolge({name:formUsername, password:formPassword}) .then(function(data){ console.log("here is the data from the service", data); alert(data); alert("cefdvefv"); }) return; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much all of you for all your answers and
CHRIS P. (Intel) wrote:, you help me understanding web services logic.
Have a nice day :))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My webservice is simple, IK call it as a PHP in a server, the php do the job on a wsdl webservice and returme a JSON object, like in the developer, I can get this JSON return, and assign the columns I want to put in a control like a ListView ?
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your app.js from the results of your JSON build a string containing HTML listview and then display it on a named <div></div> placed on your page in the desired location.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can do it directly ?
I can populate the ListView Objectg in the code ?
Thank you again

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page