BizTalk WMI Remote Wrapper - wmi

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.

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

Common Data Model with wso2bps and wso2greg

I am evaluating wso2 and came across the following issue: imagine that my company already has a well defined Common Data Model for their business. Those schemas (and even service definitions - wsdls) live on a repository and references between files are done using relative paths between them. Now, what I want is to import all of these XSD's and WSDL's into wso2 Gorvernance Registry (wso2greg) to make it manage them. More (and this is where I start to lose the grip on wso2) I want to reference wso2greg's resources on wso2bps's BPEL Workflows. I want to say: "Hey, workflow! Forget all about your auto-generated interface. Your interface will be this one {wsdl_from_wso2greg}."
I am trying to accomplish this by creating an Registry Resources Project inside my "main" Carbon Application Project (along-side with my BPEL Workflow) and then creating PartnerLinks on the workflow but, after I configured everything, I get the following error: "The import location of ../TestGreg/TestServiceWsdl.wsdl is not supported by this implementation. Import artifacts must be contained within the folder hierarchy that has the deployment descriptor at the root".
Now, am I doing something really stupid or wso2 really does not support what I am trying to do? If so, how do you guys usually deal with these issues?
Thks,
Leandro Nunes
When you are referring to WSDLs/XSDs from BPEL, you need to package them with BPEL. You cannot refer the ones stored in the registry.
Referring from the external registry can be done only for security policies and endpoint references. Any other resources need to be packaged with the BPEL.

Removing inscription of a COM server from registry leaves keys in HKEY_CLASSES_ROOT\TypeLib

We are retiring some old C++ COM server and replacing them with VB.NET equivalent. We want to clean the registry. We've discovered that using /u or /Unregserver would either not work or create problems, so we opted for removing the keys using a VBS script. In order to obtain the list of keys to remove we are using Process Monitor to monitor the key creation activities while registering the C++ server.
So far so good, but some keys persist in the HKEY_CLASSES_ROOT\TypeLib folder. I would like to know what is this folder and how they got there in the first place. If I manually delete my COM server GUID from there, it does not get recreated when I re-register the old component ?
Thanks.
I would recommend using a free registry cleaner if you are only doing it on a few machines. There is too much risk trying to get this right yourselves.

How can I "wrap" a Linq2Sql data context in a webservice?

Relevants: Visual Studio 2010,
WCF WebServices,
Linq2Sql,
.Net 4.0
Forgive me if this is a stupid question, but I believe I have seen something similar to what I'm trying to do.
We have a Linq2Sql data context we are using to read/write to a database. We'd like to expose a public API to the database for certain vendors. I seem to recall a way to expose most of the data context functionality through a web service without creating wrappers for all the CRUD methods manually. Anybody out there know how to do this? I seem to remember seing the data context exposed through a web service with just a few lines of code.
We would also need to deny access to some methods, based on permissions, but can probably work through that ourselves.
Not sure what you saw or refer to... but WCF Data Services seem to be what you are after - check them out at http://msdn.microsoft.com/en-us/data/bb931106.aspx
#Yahia got me pointed in the right direction. This article is nearly what I was looking for, but deals with ADO.Net Entity Data Models rather than LINQ data contexts. Very nearly there...
Data Access with ADO.Net Data Services.
So, it turns out the answer is pretty simple.
Create a new ASP.Net web application.
Right-click the web application.
Add --> New Item --> WCF Data Service.
Modify the code to support your context:
using System.Data.Services;
using System.Data.Services.Common;
namespace DelvingWare.Data.FilestreamServer.WebServices
{
public class WcfDataService1 : DataService<MyDataContext>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("MyEntitySet", EntitySetRights.ReadSingle);
config.SetServiceOperationAccessRule("MyEntitySet", ServiceOperationRights.ReadSingle);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
}
Build --> Right Click Service --> View In Browser. Voila!

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

[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.