consume a web service with C #, using Javascript? [closed]

0

I have a web page on the client side that works with Javascript to show information, but I want to consume a web service so that the user can interact with that page and not only ask about it, the problem is that the web service can only be consumed with .NET languages (C ++, C #, F # and VB).

I would like to know the form or to know if it is possible to create the connection to the web service from C #, and using Javascript to pass the parameters to it and execute the methods contained in C #.

(The web service I want to consume is Microsoft's Master Data Manager)

    
asked by Larry 20.09.2017 в 00:27
source

1 answer

1

What you could do is create a Web Api in c # that is the intermediary between your web application and your service .

For example if your service returns the statement of accounts it would be like this:

public class CuentasController : ApiController
{
    [HttpGet]
    public IHttpResponseMessage ObtenerEstadoCuenta(int clienteid)
    {
       var estadosCuentaServicio = new EstadoCuentaServicio();

       return Ok(estadosCuentaServicio.ObtenerEstadosCuentaClient(clienteId);
   }
}

Then to get the data from javascript with jquery it would be:

$.get("http://nombre_aplicacion/api/cuentas/obtenerestadocuenta?clientid=2", function(estados){
  // procesas los estados
});

The website has many tutorials that you could take a look at.

    
answered by 20.09.2017 в 02:33