Is it possible to run multiple versions of the same webservice? - web-services

[RUN DOWN]
I am required to call on a webservice with version information embedded in the webservice name.
EG. webserviceV1
When I generate a proxy class from the wsdl the webservice name is used to as the class name.
I am using the wsdl.exe tool.
I can foresee that a new version of the webservice would result in my code base having to support 2 sets of proxy classes. Or for the code that use the existing proxy classes to be renamed.
[MY QUESTION]
I would like to propose a solution to the provider that would allow them to provide multiple versions of the webservice as it is early on in the project.
I was advised that a possible solution would be to provide the webservice via different ports.
However having tried myself I don't know if that is even possible via IIS.
Is it possible to run multiple versions of a webservice at the same time on the same machine?

Sure it is possible. Instead of appending version numbers to webservice classes, place them in separate virtual directories:
http://host/services/1.0/service.asmx
http://host/services/1.3/service.asmx
http://host/services/2.0/service.asmx
You will then have to devise a versioning scheme (use branches properly; see this for some thoughts on that) to support all versions of service simultaneously.
As for the code, you can try abstracting differences between service versions behind a common interface (think AbstractService) and then use it as a base for version-specific implementations (ServiceV1_3).
Google gives pretty nice results for this exact topic.

Related

Dynamic database connection in Symfony 4

I am setting up a multi tenant Symfony 4 application where each tenant has it's own database.
I've set up two database connections in the doctrine.yaml config. One of the connections is static based on an env variable. The other one should have a dynamic URL based on a credential provider service.
doctrine:
dbal:
connections:
default:
url: "#=service('provider.db.credentials').getUrl()"
The above expression "#=service('provider.db.credentials').getUrl()" is not being parsed though.
When injecting "#=service('provider.db.credentials').getUrl()" as argument into another service the result of getUrl() on the provider.db.credentials service is injected. But when using it in the connection configuration for doctrine the expression is not being parsed.
Does anyone have an idea how to solve this?
You're trying to rely on ability of Symfony services definition to use expressions for defining certain aspects of services. However you need to remember that this functionality is part of Dependency Injection component which is able (but not limited to) to use configuration files for services. To be more precise - this functionality is provided by configuration loaders, you can take a look here for example of how it is handled by Yaml configuration loader.
On the other hand configuration for Doctrine bundle, you're trying to use is provided by Config component. A fact that Dependency Injection component uses same file formats as Config component do may cause an impression that these cases are handled in the same way, but actually they're completely different.
To sum it up: expression inside Doctrine configuration does not work as you expecting because Doctrine bundle configuration processor doesn't expect to get an Expression Language expression and doesn't have support for handling them.
While explanations given above are, hopefully, answers your question - you're probably expecting to get some information about how to actually solve your problem.
There is at least 2 possible ways to do it, but choosing correct way may require some additional information which is out of scope of this question.
In a case if you know which connection to choose at a time of container building (your code assumes that it is a case, but you may not be aware about it) - then you should use compiler pass mechanism yo update Doctrine DBAL services definitions (which may be quite tricky). Reason for this non-trivial process is that configurations are loaded at the early stages of container building process and provides no extension points. You can take a look into sources if necessary. Anyway, while possible, I would not recommend you to go in this way and most likely you will not need it because (I suppose) you need to select connection in runtime rather then in container building time.
Probably more correct approach is to create own wrapper of DBAL Connection class that will maintain list of actual connections and will provide required connection depending on your application's logic. You can refer to implementation details of DBAL sharding feature as example. Wrapper class can be defined directly through Doctrine bundle configuration by using wrapper_class key for dbal configuration

Can I safely use two different versions of a service in the same time?

I would be interested if I can use safely two different version of a web-service.
The schema behind the service were updated between versions, but the part that in I use were in practice unchanged (only attributes I never used where removed and I'm not going to use the newly added ones).
After building my application and sending requests to the different versions of the service my application seams to be working fine without any error.
What I'm interested if there is any pitfall that I didn't think of? Does this really work this nicely?
I did it exposing EJB3 as WS. Basically if you only add new methods to your ws and attributes to your objects, old clients can continue to connect to either new and old web-services transparently.
It is quite risky, because you have to be at least sure you haven't modified existing methods signature or, for example, changed type to object's existing attributes.
Take a look at new generated WSDL and compare it with existing generated by old WS).
Hope this helps.
It just depends on the way the Web Service versioning was implemented, if both the versions of the service are going against same Datasource, then you may not have much issues.
Usually the trend if there is a newer version of the WSDL if means the service provider will sooner or later push all the clients to newer version, I would always prefer to be on the latest version just to avoid statements like "You are using a older version of Service & we won't fix any issues on the legacy version".

How do you configure WorkManagers in WebLogic 10.3?

I would like to use a WorkManager to schedule some parallel jobs on a WebLogic 10.3 app server.
http://java.sun.com/javaee/5/docs/api/javax/resource/spi/work/WorkManager.html
I'm finding the Oracle/BEA documentation a bit fragmented and hard to follow and it does not have good examples for using WorkManagers from EJB 3.0.
Specifically, I'd like to know:
1) What exactly, if anything, do I need to put in my deployment descriptors (ejb-jar.xml and friends)?
2) I'd like to use the #Resource annotation to inject the WorkManager into my EJB 3 session bean. What "name" do I use for the resource?
3) How do I configure the number of threads and other parameters for the WorkManager.
My understanding is that the underlying implementation on WebLogic is CommonJ, but I'd prefer to use a non-proprietary approach if possible.
First, you'll find the documentation of CommonJ, an implementation of the Timer and Work Manager API developed by BEA Oracle and IBM, in Timer and Work Manager API (CommonJ) Programmer’s Guide. They provide a Work Manager Example but it's not injected in this document.
1) What exactly, if anything, do I need to put in my deployment descriptors (ejb-jar.xml and friends)?
According to the Work Manager Deployment section:
Work Managers are defined at the
server level via a resource-ref in the
appropriate deployment descriptor.
This can be web.xml or ejb-jar.xml
among others.
The following deployment descriptor
fragment demonstrates how to configure
a WorkManager:
...
<resource-ref>
<res-ref-name>wm/MyWorkManager</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
...
Note: The recommended prefix for the JNDI namespace for WorkManager
objects is java:comp/env/wm.
Check the WorkManager javadocs for more details (e.g. "The res-auth and res-sharing scopes are ignored in this version of the specification. The EJB or servlet can then use the WorkManager as it needs to.").
2) I'd like to use the #Resource annotation to inject the WorkManager into my EJB 3 session bean. What "name" do I use for the resource?
I'd say something like this (not tested):
#ResourceRef(jndiName="java:comp/env/wm/MyWorkManager",
auth=ResourceRef.Auth.CONTAINER,
type="commonj.work.WorkManager",
name="MyWorkManager")
3) How do I configure the number of threads and other parameters for the WorkManager.
See the description of the <work-manager> element and Using Work Managers to Optimize Scheduled Work for detailed information on Work Managers
My understanding is that the underlying implementation on WebLogic is CommonJ, but I'd prefer to use a non-proprietary approach if possible.
I don't have any other suggestion (and, as long as this implementation follows the standards, I wouldn't mind using it).
The Weblogic documentation will answer your questions.
Using Work Managers to Optimize Scheduled Work

What GUI tool can I use for building applications that interact with multiple APIs?

My company uses a lot of different web services on daily bases. I find that I repeat same steps over and over again on daily bases.
For example, when I start a new project, I perform the following actions:
Create a new client & project in Liquid Planner.
Create a new client Freshbooks
Create a project in Github or Codebasehq
Developers to Codebasehq or Github who are going to be working on this project
Create tasks in Ticketing system on Codebasehq and tasks in Liquid Planner
This is just when starting new projects. When I have to track tasks, it gets even trickier because I have to monitor tasks in 2 different systems.
So my question is, is there a tool that I can use to create a web service that will automate some of these interactions? Ideally, it would be something that would allow me to graphically work with the web service API and produce an executable that I can run on a server.
I don't want to build it from scratch. I know, I can do it with Python or RoR, but I don't want to get that low level.
I would like to add my sources and pass data around from one service to another. What could I use? Any suggestions?
Progress DataXtend Semantic Integrator lets you build WebServices through an Eclipse based GUI.
It is a commercial product, and I happen to work for the company that makes it. In some respects I think it might be overkill for you, as it's really an enterprise-level data mapping tool for mapping disparate data sources (web services, databases, xml files, COBOL) to a common model, as opposed to a simple web services builder, and it doesn't really support your github bits, anymore than normal Eclipse plugins would.
That said, I do believe there are Mantis plugins for github to do task tracking, and I know there's a git plugin for Eclipse that works really well (jgit).
Couldn't you simply use Selenium to execute some of this tasks for you? Basically as long as you can do something from the browser, Selenium will also be able to do. Selenium comes with a language called "selenese", so you can even use it to programmatically create an "API" with your tasks.
I know this is a different approach to what you're originally looking for, but I've been using selenium for a number of tasks, and found it's even good to execute ANT tasks or unit tests.
Hope this helps you
What about Apache Camel?
Camel lets you create the Enterprise Integration Patterns to implement routing and mediation rules in either a Java based Domain Specific Language (or Fluent API), via Spring based Xml Configuration files or via the Scala DSL. This means you get smart completion of routing rules in your IDE whether in your Java, Scala or XML editor.
Apache Camel uses URIs so that it can easily work directly with any kind of Transport or messaging model such as HTTP, ActiveMQ, JMS, JBI, SCA, MINA or CXF Bus API together with working with pluggable Data Format options.

BizTalk WMI Remote Wrapper

I'm using MgmtClassGen.exe from the .Net Framework SDK to generate some WMI wrapper classes for BizTalk artifacts like hosts, host instances, etc.
I'm using HostSetting.GetInstances() to get the local hosts (local BizTalk Server). This works fine. I'm now looking for a way to do the same for hosts on another BizTalk machine with a different BizTalk management database name. I can't find a way to do this using the wrapper classes. I do want the wrapper classes. Any idea how to connect to BizTalk Management database with name 'MyManagementDB' on server 'ServerX'?
Thanks in advance!
You can choose a different server to connect to by specifying it in the WMI scope declaration.
In your code you will have something like the following:
ManagementClass objHostSettingClass = new ManagementClass("root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);
The first parameter in the constructor call there is the scope. This can include a server name as shown below:
ManagementClass objHostSettingClass = new ManagementClass("\\\\ServerX\\root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);
I don't believe that you will need to know the message box name - the WMI MicrosoftBizTalkServer provider should let you access the host instances on the server directly.
EDIT
As Maxime points out in the comment below, there is a way of setting the WMI scope that more integrated with the code generated by the MgmtClassGen.exe tool.
This allows you to set the StaticScope property of the generated classes. This still involves building a string defining the scope but gives a single place to define it. Maxime has a nice post defining a helper class that builds the StaticScope string.
I know this could be considered off topic since you are somewhat asking specifically of WMI, but there is also a .NET library that provides access to all of the BizTalk artifacts called Microsoft.BizTalk.ExplorerOM.dll. I used it to turn on/off receive locations in a small C# app. Here is a link to my previous Stack Overflow question with more information:
Is there a way to automate turning a BizTalk Receive Location on or off through code?
Just another option for altering or administrating BizTalk artifacts through code.