How to dynamically configure a web service connection endpoint?

Hi,

 

We have a segregated development and live environment, which is pretty standard. I am looking at implementing web services using the Web Service 'Connection' type from within Metastorm, exposing the relevant methods.

 

This web service has a specific endpoint from within our development environment, which I can use to create a Server Script to implement the methods. I have a solution that deploys into this environment and tests successfully.

 

Now, when we get to the point that we want to release this to a live environment, I need the ability to change the endpoint from the development one to the live one without having to change the connection parameters within the solution. Many developers may be working on this code and the risk is too high that this step would be forgotten and subsequently breaks the live environment.

 

Can this be done? Is there some way of making this dynamic in code (so that we could look this up from a configuration setting / database)?

 

Thanks in advance,

 

Nils.

Tagged:

Comments

  • I've used this for other types of connections as I don't have a need for web connections thus far.

     

    What about defining the connection in a library and include the library in your solution(s).  The library in each environment would contain specifics for that particular environment.  This way the base solution doesn't change, but the library defines its needs for each environment.

  • Assuming you are using the native Connection type to manage your connections to these web services, you should be able to edit those ServiceModel details (including the endpoint) via the Admin Tools interface (ServiceModel details look like what VS puts into an app.config). This should allow you to deploy the identical projects to all environments, then log in as SysAdmin and tweak the ServiceModel details through the browser in Admin Tools.

     

    However, there is an open defect logged in our system for 9.1.3... This is scheduled to be fixed in 9.2.1 which should be out sometime in Q4. This defect may affect other versions as well. Unfortunately, this would require an upgrade of your system should you want to use this feature because it is not working in 9.1.3. The workaround is to document release steps that involve changing those details on the Connection objects for each environment directly in the Project before deployment.

     

    When this is working as designed, the standard way to do this is as follows (the 9.1.3 Admin Guide Section 5.5.5 goes into some detail on this). To edit connection details, go to Admin Tools > Metastorm Repository > Projects > Connections. You should see a list of all your project’s connections and if you click on them, you should be able to edit the connection string details (for database connections) and ServiceModel.config details (for web services). After editing, click the “Overridden” checkbox and click the green check mark to save.

     

  • Hi Tony,

     

    I have MBPM 9.2.1 installed and am trying to configure a Web Service connection in the Admin Tool, but I get a javascript error while trying to save or cancel. Do I have IIS configured incorrectly or is this a bug?

  • Just opened a ticket in regards to this.

     

    Didn't work in 9.2 or 9.2.1 or 9.2.1 hot fix 3

  • As a follow up, it works in 9.3. I figured out that I had an issue with something on my side and this feature probably works in 9.2 - But, I can't say for certain if this is (or is not) an issue on 9.2...

  • Hi,

     

    I have a library which contains all web-service Connections such as:

    ERP_DEV

    ERP_TEST

    ERP_PROD

     

    In the server side script I have a function which checks which engine (eEngine) is running and based on this parameter it will run the relevant web-service method based on environment.

    This could be cumbersome for multiple web-service methods, however this works for me as I only use a few.

     

    The positive is that there is no maintenance of connections when bouncing between different environments.

     

    Cheers.

  • The way I got around it in the end was to use the web service through a server side script, specifying the endpoint and bindings on the fly from settings in a data table.

     

    using System.ServiceModel;
    using Metastorm.Runtime.Models.<Mstm Project>.WCF.<Mstm Webservice Proxy>;
    
    EndpointAddress endpoint = new EndpointAddress(<URL from DB>);
    NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
    Int32 maxLength = Convert.ToInt32(<Maximum Data Length from DB>);
    binding.MaxBufferSize = maxLength;
    binding.MaxReceivedMessageSize = maxLength;
    binding.ReaderQuotas.MaxStringContentLength = maxLength;
    
    using (<WS Class Name> client = new <WS Class Name>(binding, endpoint)) {
            client.<WS Class Method>();
    }
    

    This will require a connection having been setup at some point and the proxy connection created within Metastorm.

     

    The only downside is that this will not help if you need to use the web service methods directly, say in a business object, without having to create some server side scripting.

     

    As this met our requirements at the time, I have also not looked into whether this works on 9.3. Yet.

     

    Hope this helps someone.

     

    Nils.

  • Thanks a million!
    I have been looking for a solution like this for a long time, you really made my day. The only thing that was a problem initially for me was that in your example you used NetTcpBinding and my Service needed BasicHttpBinding but when I sorted that out everything workded like a charm. Thanks.
    /Henrik