Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consuming web service in HTML

I have created a web service and saved its .wsdl file. I want to consume this service in my HTML file by providing its URL.

Can anybody tell me how to call the URL in HTML and use it? Like its done here. http://www.codeproject.com/Articles/14610/Calling-Web-Services-from-HTML-Pages-using-JavaScr/

The only difference is my web service does not have an extention like "asmx?wsdl". Does that makes any difference. I followed that tutorial too but it does not produce any output.

Thank You////

like image 837
NewBee Avatar asked Apr 02 '13 09:04

NewBee


2 Answers

You definitly should get familiar with AJAX. You could use the ajax functionalities provided by jQuery. That's the easiest way, I assume. Take a look at http://api.jquery.com/jQuery.ajax/

You can use this like

$.ajax({
  url: "urltoyourservice.xml"
  dataType: "xml",
}).done(function(data) {
  console.log(data);
});

HTML itself cannot consume a webservice. Javascript ist definitely needed. The existence of your WSDL File looks like you are probably using a XML format as the return of the web service. You have to deal with XML in javascript. Therefore take a look at Tim Downs explanation.

But keep in mind, that your web service URL must be available under the same domain as your consumption HTML-File. Otherwise you'll receive a cross-site-scripting error.

like image 105
thomas Avatar answered Oct 09 '22 07:10

thomas


yes you can use ajax but keep in mind you wont be able to make a request across domains. Consuming web services should be done in server side.

To further gain more knowledge about this, read How do I call a web service from javascript

like image 31
lngs Avatar answered Oct 09 '22 09:10

lngs