locked
WCF web service call another web service RRS feed

  • Question

  • User206446733 posted

    I no idea how to implement below situation

    Web Service 1 - Receive request from the user and pass to web service 2 to do the processing.

    Web Service 2 - Will handle the processing such as CRUD and pass back to web service 1.

    I already completed the web service 2 just stuck in the web service 1. Web service 1 serve as the entry point to all the request.

    Anyone please help. Thanks.

    Wednesday, November 20, 2013 3:10 AM

Answers

  • User-488622176 posted

    Web services do not pass data back to other web services... You either call a service and wait for the result, or you call the service and do not want result. You can call a service async, which means you wait for the result but you can to other things in the mean time.

    What I'd do in your case:

    • Make a web application with a WCF service handling your 2nd requirement. This WCF service wil have a method linke "public MyResult ThisIsAMethod(MyRequest req);"
    • Make a second web application with a second WCF service handling your 1st requirement. Start your first web application in debug mode (meaning : start the WCF service). Then add a service reference to your other web project. This will generate the proxies.

    In terms of performance you'll get the worst case scenario. If you want to do thing much more efficient:

    • Make a web application with a WCF service handling your 2nd requirement. This WCF service wil have a method linke "public MyResult ThisIsAMethod(MyRequest req);"
    • Add a new WCF service to this project handling your 1st requirement. In order to call your service created in the previous bullet, use a "new MyService1()" where MyService1 is the name of your WCF service

    WCF services are merely classes that are exposed to the outside world by a WCF layer...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2013 9:29 AM
  • User-484054684 posted

    Sorry I new to WCF. if the web service 1 and web service 2 is in different project. It is the same method by using the add the service reference to the project ? Thanks

    Yes ofcourse you can call one webservice from other webservice just by adding the service reference to the project.

    But as long as you are introducing more webservices for one transaction, it is one additional HTTP request you are making on the network. So, keeping performance under consideration, if you can do everything in one webservice that would give more performance. However that depends based on your architectural decision if both the webservices are being developed by separate parties or if your webservices needs to be exposed to different service providers.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2013 12:57 PM

All replies

  • User-775697465 posted

    You can call web service1 from web service2 by adding a web reference for web service1 to webservice 2 same as you consumming a web service from client application

    Wednesday, November 20, 2013 3:51 AM
  • User1079421601 posted

    simply call another web service as you call from a page. Her is the sample exampl

    Wednesday, November 20, 2013 4:13 AM
  • User206446733 posted

    Sorry I new to WCF. if the web service 1 and web service 2 is in different project. It is the same method by using the add the service reference to the project ? Thanks

    Wednesday, November 20, 2013 4:35 AM
  • User-488622176 posted

    Web services do not pass data back to other web services... You either call a service and wait for the result, or you call the service and do not want result. You can call a service async, which means you wait for the result but you can to other things in the mean time.

    What I'd do in your case:

    • Make a web application with a WCF service handling your 2nd requirement. This WCF service wil have a method linke "public MyResult ThisIsAMethod(MyRequest req);"
    • Make a second web application with a second WCF service handling your 1st requirement. Start your first web application in debug mode (meaning : start the WCF service). Then add a service reference to your other web project. This will generate the proxies.

    In terms of performance you'll get the worst case scenario. If you want to do thing much more efficient:

    • Make a web application with a WCF service handling your 2nd requirement. This WCF service wil have a method linke "public MyResult ThisIsAMethod(MyRequest req);"
    • Add a new WCF service to this project handling your 1st requirement. In order to call your service created in the previous bullet, use a "new MyService1()" where MyService1 is the name of your WCF service

    WCF services are merely classes that are exposed to the outside world by a WCF layer...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2013 9:29 AM
  • User-484054684 posted

    Sorry I new to WCF. if the web service 1 and web service 2 is in different project. It is the same method by using the add the service reference to the project ? Thanks

    Yes ofcourse you can call one webservice from other webservice just by adding the service reference to the project.

    But as long as you are introducing more webservices for one transaction, it is one additional HTTP request you are making on the network. So, keeping performance under consideration, if you can do everything in one webservice that would give more performance. However that depends based on your architectural decision if both the webservices are being developed by separate parties or if your webservices needs to be exposed to different service providers.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2013 12:57 PM