5

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////

1

3 Answers 3

9

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.

1

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

1
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 this it will help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.