Aditya Yadav & Associates

Architecting World Class Engineering Companies

Home
Mobile
Books
Amazon Cloud Computing Wi
Amazon Cloud Computing Wi
Understanding Programming
Deploying HTML5
Cross Platform POX Json J
CloudEase - Enterprise
Pocket Guides
Research Reports
Products
Consulting
CloudEase - Enterprise
User eXperience
Presentations
EAI / SOA / ROA / MOA
CEP
GPU/FPGA
QA
Web2.0 & Enterprise2.0
Internet Scale Websites
Cloud Computing
Peer To Peer
Technology Strategy
Agile
Lean
Labs
Articles & Whitepapers
Blogs
Podcasts
Videocasts
Training
Tools We Recommend
Press Release(s) And News
The Way We Work
Contact Us
 
Cross Platform POX Json JsonP Restful Web Services With C#/WCF Java/RestEasy And Ajax  
Buy the PDF/eBook Version Here (supported devices)  Buy On Amazon Kindle Store

Product Description
 

<TBD>

 

Download source code accompanying the book here
 

 

Java/JAX-RS JsonP Example

 

JsonP is a mechanism to deliver JSON as a javascript file thus bypassing the Same-Origin constraints. Most of the Internet Applications expose a JsonP API. In the example we create a Json Service using RestEasy which is JAX-RS compliant. And then we wrap the Json service with a JsonP filter which gets activated only if the, "http://.. : .. /...?callback=something", callback request parameter is included in the get request in which case it wraps the Json output and returns JsonP. The Json Service returns an object with Name and Email. The Ajax web page makes the JsonP call and displays the Name and Email on the browser.

 

Before the web page makes the JsonP Ajax request the page shows as below.

 

 

 

After the web page makes the JsonP Ajax request the page shows as below.

 

 

Please hit the Java/RestEasy JsonP service directly using http://localhost:8090/JavaJsonPService/rest/nae/json?callback=myjavascriptmethod to see the JsonP response. Replace the port with the port number of your server instance.

 

 

C#/WCF JsonP Example

 

In the example we create a Json Service using WCF. And then we annotate the Json service method with a JsonP annotation which gets activated only if the, "http://.. : .. /...?callback=something", callback request parameter is included in the get request in which case it wraps the Json output and returns JsonP. The Json Service returns an object with Name and Email. The Ajax web page makes the JsonP call and displays the Name and Email on the browser.

 

After the web page makes the JsonP Ajax request to the C# JsonP service the page shows as below.

 

 

 

Both the examples above will return a normal Json response if the 'callback' parameter is not passed in the request url.

 

Please hit the C#/WCF JsonP service directly using http://localhost:3687/CSharpJsonPService/NameAndEmailService.svc/json?callback=myjavascriptmethod to see the JsonP response. Replace the port with the port number of your server instance.

 

Download the source code for both the Java and C# JsonP examples here