locked
Web API as Middleware RRS feed

  • Question

  • User1347113063 posted

    So I am fairly new to this concept so I need some help and directions.

    What I am basically planning to do is calling my created web api from a sql database then MyWeb api will call an external api which will perform an action. 

    Here is the full scenario that should be done:

    Through the sql I am going to send these specific parameters  -WorkerId, Name and Email -  to MyWeb Api which in terms will call the external API which will perform the action of sending emails to these workers

    I have been reading through this https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-2 but it's lacking a lot of information that I need so can anyone direct me ??

    Saturday, November 9, 2019 3:19 PM

All replies

  • User475983607 posted

    Middleware runs in the HTTP pipeline which happens before and after an HTTP request to a Web API Action.   I don't get the Web API as middleware requirement. 

    TC20

    Through the sql I am going to send these specific parameters  -WorkerId, Name and Email -  to MyWeb Api which in terms will call the external API which will perform the action of sending emails to these workers

    If you wrote code to make an HTTP request from SQL then just call the external Web API directly.  There no logical reason to call a Web API that calls another Web API.

    TC20

    I have been reading through this https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-2 but it's lacking a lot of information that I need so can anyone direct me ??

    What information is missing?

    Saturday, November 9, 2019 3:46 PM
  • User1347113063 posted
    We need to do this as we don’t want the external API to have a direct communication with our database for security measures and for the article that I have mentioned there’s no references to either how can call an external api nor does it have how we can receive specific data from the database
    Saturday, November 9, 2019 4:09 PM
  • User-474980206 posted

    The sample you refer to is accessing a sql database from a web service, not the database calling a web service. It’s not really recommended to call a web service, but the most typical solution is to use a CLR module,  google for Sqlserver CLR web service call.

    Your webapi would just be a proxy to the real webapi. You can google for samples as this is common for Ajax calls to be a proxy. You can also configure IIS to be the proxy, with no coding required.

    Saturday, November 9, 2019 5:00 PM