Using AJAX Web Services Directly

I am currently developing a website for the public transport system based on the Trafikanten API ( http://reis.trafikanten.no/topp2009/topp2009ws.asmx )

The site has several features, although these are web services. It is implemented in the .NET environment with the SOAP format. But we need to use its functionality in a client language, such as JavaScript, in order to be able to display information on a web page. Can anyone suggest an easy way to handle this scenario?

+3
source share
3 answers

If you are using the LAMP stack:

PHP script, nusoap (http://sourceforge.net/projects/nusoap/) libarary, - SOAP JSON JavaScript AJAX.

Edit

.NET. " -". - , . JS, ASP-, JSON, , jQuery, LAMP-. , ASP JS - .

, .

+2

JSONP, , , ASMX, - -. , , .

Top2009WS ASP.NET, - - GetLines(), :

[WebMethod]
public Line[] GetLines(int ID) {
  var client = new Topp2009WS.Topp2009WSSoapClient();

  client.open();

  return client.GetLines(ID);
}

-, :

$.ajax({
  url: 'Service.asmx/GetLines',
  type: 'POST',
  dataType: 'json',
  contentType: 'application/json',
  data: '{"ID":' + 12345 + '}',
  success: function(response) {
    // Alerts the first result "LineName"
    alert(response.d[0].LineName);
  }
});

. jQuery -.

+1

, , .NET. " " , . SOAP .NET, JSON .

0

Source: https://habr.com/ru/post/1792847/


All Articles