Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Runtime Web Service Invocation

Runtime Web Service Invocation

Scheduled Pinned Locked Moved C#
questionwcfbusiness
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrEyes
    wrote on last edited by
    #1

    Hello all, I am just starting a project that requires me to create a base application/service to act as a proxy between clients and webservices. Nice and simple, if I have all the relevant WSDL files at compile time. However part of the requirements is that this application is extensible. In other words, once developed a "support" person can drop a new WSDL file into the application and without recompiling this becomes immediately available. So the question is, does anybody know of a way that this can be done?

    E 1 Reply Last reply
    0
    • M MrEyes

      Hello all, I am just starting a project that requires me to create a base application/service to act as a proxy between clients and webservices. Nice and simple, if I have all the relevant WSDL files at compile time. However part of the requirements is that this application is extensible. In other words, once developed a "support" person can drop a new WSDL file into the application and without recompiling this becomes immediately available. So the question is, does anybody know of a way that this can be done?

      E Offline
      E Offline
      ElSpinos
      wrote on last edited by
      #2

      Hey there MrEyes, You’ve been posed with a tough one there and you might have to do some research on the following topic: Reflection and runtime target invocation. In a nut shell, you will need to implement the following strategy in your proxy assembly: * You will need to create a public interface that all your web services must implement. The reason being that your proxy will need this metadata to expose the underlying functionality to the caller and identify the service as a deployable package. * You will need to implement a directory search service that looks for new web services and checks for the presence of the public interface you implemented above. Store the value away in a file or database so that you have a list of web services you know about. * Through runtime target invocation, you can now call the web service functionality dynamically; you will need knowledge of the Reflection namespace to achieve your goal. I hope I’ve pointed you in the right direction for now, good luck. :)

      Fernando Mendes Senior .NET Developer, Architect

      M 1 Reply Last reply
      0
      • E ElSpinos

        Hey there MrEyes, You’ve been posed with a tough one there and you might have to do some research on the following topic: Reflection and runtime target invocation. In a nut shell, you will need to implement the following strategy in your proxy assembly: * You will need to create a public interface that all your web services must implement. The reason being that your proxy will need this metadata to expose the underlying functionality to the caller and identify the service as a deployable package. * You will need to implement a directory search service that looks for new web services and checks for the presence of the public interface you implemented above. Store the value away in a file or database so that you have a list of web services you know about. * Through runtime target invocation, you can now call the web service functionality dynamically; you will need knowledge of the Reflection namespace to achieve your goal. I hope I’ve pointed you in the right direction for now, good luck. :)

        Fernando Mendes Senior .NET Developer, Architect

        M Offline
        M Offline
        MrEyes
        wrote on last edited by
        #3

        Well based on your comments and some research the general plan of action is something like the following: The "Proxy" service exposes a "CallWebService" method that takes an XML structure as one of the parameters. This structure will look something like the following:

        <CallData webserviceName="mywebservice">
        <parameters>
        <parameter key="input1" value="input 1 data"/>
        <parameter key="input2" value="input 2 data"/>
        <parameter key="input3" value="input 3 data"/>
        </parameters>
        </CallData>

        When the "proxy" receives this request the following occurs: 1) Loads the relevant WSDL and associated config (i.e. endpoint, timeouts etc) from the "webservicename" attribute (probably from a DB). 2) From the WSDL data constructs an empty soap message to be posted, i.e. something like this

        POST /Service1.asmx HTTP/1.1
        Host: localhost
        Content-Type: text/xml; charset=utf-8
        Content-Length: length
        SOAPAction: "http://services.com/mywebservice"

        <?xml version="1.0" encoding="utf-8"?$gt;
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"$gt;
        <soap:Body$gt;
        <mywebservice xmlns="http://messaging.external.e-mis.com/"$gt;
        <input1$gt;</input1$gt;
        <input2$gt;</input2$gt;
        <input3$gt;</input3$gt;
        </mywebservice$gt;
        </soap:Body$gt;
        </soap:Envelope$gt;

        1. From the submitted parameter data adds the relevant values to the relevant element in the soap message 4) Posts the full formed SOAP message to the configure endpoint 5) When the sync reply is received, it extracts the return data and puts this into a similar XML structure to the one that the client submitted, e.g.

        <ResultData>
        <results>
        <result key="input1" value="input 1 data"/>
        <result key="input2" value="input 2 data"/>
        </results>
        </CallData>

        And then returns this back to the client Point number 2 is where things get a little complicated. Having hunted around a little I have found a sample here on codeproject: http://www.codeproject.com/cs/webservices/wsdlparser.asp[^] I believe that this will do what I need, however it needs some hacking

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups