Using a web service in HTML

I created a web service and saved its .wsdl file. I want to use this service in my HTML file, specifying its URL.

Can someone tell me how to call a url in HTML and use it? How is it done here. http://www.codeproject.com/Articles/14610/Calling-Web-Services-from-HTML-Pages-using-JavaScr/

The only difference is that my web service does not have an extension such as "asmx? Wsdl". It matters. I also followed this tutorial, but it did not produce any results.

Thanks.////

+4
source share
3 answers

You should definitely familiarize yourself with AJAX . You can use the ajax functions provided by jQuery. This is the easiest way, I suppose. Take a look at http://api.jquery.com/jQuery.ajax/

You can use this as

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

HTML itself cannot use the web service. Javascript is definitely necessary. The existence of your WSDL file looks like you are probably using the XML format as a web service return. You have to deal with XML in javascript. So check out Tim Downs .

But keep in mind that your web service url must be accessible in the same domain as your HTML consumption file. Otherwise, you will get a cross-site scripting error .

+9
source

yes, you can use ajax, but keep in mind that you cannot make a request through domains. Consumption of web services must be done on the server side.

To learn more about this, read How do I call a web service from javascript

+1
source
 function submit_form(){ var username=$("#username").val(); var password=$("#password").val(); var data = { loginName: username, password:password }; $.ajax( { type: "POST", url:"Paste ur service address here", data: JSON.stringify(data), contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function(data){ var value = data.d; if(value.UserID != 0){ alert.html('success'); } }, error: function (e) { } }); } 

Try it, it will help

+1
source

All Articles