Web Services

Web Services

I'm new here and would like to know how to integrate the Intel XDK with Web Services from Visual Studio (with C #). I'm developer and I need to do an app for iPhone.

Thank you!

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The apps you write for your device, using the XDK, are HTML5 apps. The best way to communicate with a web service from an HTML5 app is by using a REST type interface (for example, by making XHR or Ajax calls).

The latest release of the XDK includes a "Services" tab that makes it easy to explore web services and generate a JavaScript function to then retrieve and sort through that data (the assumption is the data is being retrieved in a JSON format).

If the web services you are creating with C# and Visual Studio are meant to be run on a web server, then you are halfway there. If those services respond to standard HTTP gets and puts, etc. with JSON data, you should be able to communicate with that server from an HTML5 app in the XDK.

If I am misunderstanding your question, I apologize. If you are asking how to provide those services to an XDK app, you simply need to provide the REST interface definition to those who will use the service.

Quote:

Paul Fischer (Intel) wrote:

The latest release of the XDK includes a "Services" tab that makes it easy to explore web services and generate a JavaScript function to then retrieve and sort through that data (the assumption is the data is being retrieved in a JSON format).

I am using the 1912 version and do not have the Services tab.
I created a service through the Web Services panel and three files were created:

- xdk/services/iodocs/apiconfig.json
- xdk/services/iodocs/service.json
- xdk/services/iodocs/service.js (Note that this file was not created in the service folder)

I moved the files (service.json and service.js) for the service folder, but nothing happened differently.
So I moved the file (service.js) to service folder and let the files (apiconfig.json and service.json) in iodocs folder. No changes occurred.

How do I use the methods of that service?

Victor,

After creating a service you are asked if you want to use it in the Code Editor or in App Designer. 

If you say "Code Editor", than an unsaved Untitled file will be started for you that has some snippets for including the services, calling them, intercepting the results, etc.  You can save that file, or just copy/paste out of it into your project, or whatever.

If you choose App Designer, then you'll see the service listed in the App Designer services listing. You can drag the service instance onto a control (like a list item) and then populate the control with service data.  When you are running the Design view, you'll see a bunch of service related videos under the Help menu. They might help as well.  

The App Designer services list works regardless. So even if you chose "Code Editor" from that first question, you'll still see the services listed in A.D. 

Hope this helps,

Chris

Hi Victor, 

Hope Chris's explanation is able to help you figure out how to use the service-methods. You mention in your previous message that you moved the three files around. Please verify that all the three files : apiconfig.json, service.json and service.js are in the same folder : xdk/services/iodocs/* ..... just like you listed.

You also mention that the service.js file was not created in the services/iodocs folder like the other two, is that correct? If so, can you please try reproducing that issue and let me know the steps. All those files should have been created in the same services/iodocs/ folder. 

Once you have the project structure like this : 

-  xdk/services/iodocs/apiconfig.json
- xdk/services/iodocs/service.json
- xdk/services/iodocs/service.js 

..then open apiconfig.json and edit the line that specify the name of your service to be something like 'Visual Studio'

"service": {
    "name": "Lower Case API"
  }

to 

"service": {
    "name": "Visual Studio"
  }

A common mistake here is to change the word "service". The key value ("service") in apiconfig.json should always match the name of your .js and .json file. Once this is done, restart your XDK. In the list of services, you would be able to see 'Visual Studio' as one of the service. Then proceed with adding methods and endpoints according to the video and then using them as per Chris's explanation. 

Leave a Comment

Please sign in to add a comment. Not a member? Join today