aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Calling WebService using plain JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Calling WebService using plain JavaScript" Watch "Calling WebService using plain JavaScript" New topic
Author

Calling WebService using plain JavaScript

Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
I need to call a WebService of a different domain from my application using plain JavaScript. I don’t have a liberty to use any JavaScript/Ajax libraries - I can only use plain JavaScript.

Solution must work on IE and Firefox both.



My blood is tested +ve for Java.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Since XmlHttpRequest falls under the same-domain policy, you'll have to use JSONP.


Ping & DNS - my free Android networking tools app
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Wouldn't the web service need to support JSONP? If yes - it sounds like a good approach - otherwise traditional server proxy approach would work.

I found this an interesting read.


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

In case its not clear by what I meant by a server proxy -- you'll find some good help here -- http://www.google.com/search?q=cross+domain+javascript&ie=utf-8&oe=utf-8&aq=t
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling WebService using plain JavaScript