none
Consume soap webservice in another webservice- best appraoch RRS feed

  • Question

  • Hi,

    I need to create an API which consumes one web service and the result passed to another web service (asmx).The request is sent to the first web service with a soap input. So I have following questions.

    1) Can I use the method used in the following link to consume a soap web service(first web service) with soap request?(without using proxy class)

    How to call a SOAP web service in .NET 4.0 C# without using the WSDL or proxy classes

    Or I should use the "Add web reference" approach (to get client proxy of the web service)? Which is the best approach?

    2) Is it okay if I create a WCF soap service as the API? (As I said my requirement is to create an API which consume one web service and the result passed to another web service).Or I should go ahead with asp.net webapi? (But that support REST service only)

    Thanks.

    Monday, August 18, 2014 8:13 AM

Answers

  • Hi,

    To simplify development of XML Web service client applications, Visual Studio provides Web references. Web references differ from traditional references and components; instead of referencing a component or a class library installed on the local computer, a Web reference provides access to a resource that is available using an Internet protocol such as SOAP or HTTP.

    In practice, a Web reference is a generated proxy class that locally represents the exposed functionality of an XML Web service. The proxy class defines methods that represent the actual methods exposed by an XML Web service. When your application creates an instance of the proxy class, your application can call the XML Web service methods as if the XML Web service were a locally available component.

    This is a fair enough requirement that you might come across in multiple scenarios. Here are some situations, that come to my mind, where this approach might come handy:
    •Loosely coupled integration in Application Service Provider Model - Application Service Provider Model is a model where a single web application can support users from multiple clients. In this scenario, there is often a need to allow the application to call different web services depending on the client, and it may not always be a good idea to do a web reference to each and every one of those web services, specially when they have exactly the same specification.
    •Dynamically invoking different Web Services during runtime - There are two or more completely different web services with the same WSDL specification but different implementation inside functions and business logic. If the application needs to decide which web service to invoke depending on the flow / business logic, during runtime, then it may be a good idea to take up this approach.

    For detailed information, you could refer to:

    http://www.codeproject.com/Articles/14586/Invoking-a-Web-Service-Without-Web-Reference

    Regards

    Tuesday, August 19, 2014 9:41 AM
    Moderator