How to invoke methods on external server / webservice?

↘锁芯ラ 提交于 2019-12-30 12:13:45

问题


I'm trying to invoke methods from http://www.ibanbic.be/IBANBIC.asmx

I have read a lot of forums and tutorials, but all the information is about setting up a webservice in ASP.net or using ajax / javascript. I just need to call the function: calculateIBAN1.

A tutorial step by step would be awesome.

Thanks in advance


回答1:


A tutorial step by step would be awesome.

Right click on the References menu in your project in the solution explorer and choose Add Service Reference.... In the address type http://www.ibanbic.be/IBANBIC.asmx and click Go and then OK. This will generate a strongly typed client proxy that will allow you to invoke the service:

using (var client = new ServiceReference1.BANBICSoapClient("IBANBICSoap"))
{
    string result = client.calculateIBAN1("iso country", "some account");
}

Notice that this will also add a <system.serviceModel> to your web.config file where you could manage the WCF client endpoints.

Alternatively you could use the svcutil.exe to generate a client proxy for the service as shown in this article on MSDN.




回答2:


ASP.NET:

First you have to add a web service:

And then you have to instantiate the webservice and call the method.

Hope it helps!




回答3:


based on their site http://www.ibanbic.be/IBANBIC.asmx?op=calculateIBAN1

You can make a simple Ajax call like this:

var ISOCountry = 'IT';
var account = 'IT60 X054 2811 1010 0000 0123 456';
var url = "http://www.ibanbic.be/IBANBIC.asmx?op=calculateIBAN1"
        jQuery.ajax({
            type: 'GET',
            url: url,
            timeout: 4000,
            data: {'ISOcountry':ISOCountry, 'account' : account},
            success: onSuccess,
            error: onError,
            dataType: 'json',
            complete: function() {
            }
        });
}
function onSuccess(data, textStatus, jqXHR) {
    // do something
}
function onError(jqXHR, textStatus, errorThrown) {
    // do something
}


来源:https://stackoverflow.com/questions/16062767/how-to-invoke-methods-on-external-server-webservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!