1

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

thomvlau
  • 602
  • 3
  • 9
  • 24

3 Answers3

2

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • The system.serviceModel is added to webconfig, so the first part worked. I'm using MVC4 so when i click the button my controller executes the http post of that page. The code that you've pasted should that be in that httppost? Thanks for answering btw – thomvlau Apr 17 '13 at 14:50
  • Strange but I get this InnerException.Message: 'Unable to connect to the remote server' – Tassisto Dec 26 '13 at 09:09
  • @BadaBoom, that's probably because the machine you are running your application in doesn't have access to the server on which the web service is hosted. Or maybe there's a firewall or proxy in between preventing the access. – Darin Dimitrov Dec 26 '13 at 09:10
  • I added code to consume Web Services without a config file - find the solution here: http://stackoverflow.com/questions/54579/wcf-configuration-without-a-config-file – Tassisto Dec 26 '13 at 09:53
0

ASP.NET:

First you have to add a web service:

enter image description here

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

enter image description here

Hope it helps!

Lexsoul
  • 155
  • 2
  • 8
  • thanks for answering, but add web reference is not in my options, add service reference is (Is this the same?). I'm using a MVC4 project maybe that's why there isn't web references? – thomvlau Apr 17 '13 at 14:47
  • Well, here is best explained about web reference and service reference (http://stackoverflow.com/questions/2158106/web-reference-vs-service-reference) but to simplify, service reference is the new way to do it. So, add the service reference and instantiate the method. – Lexsoul Apr 17 '13 at 14:56
0

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
}