How do I set BTS.Operation in a custom pipeline? - biztalk

Up until now I've only been using orchestrations in my BizTalk application and it's been working fine so far. But now I want to convert some of the unnecessary orchestrations to pure message routing instead in order to get better performance.
I've got a WCF service with only one method and that works fine because I can set the BtsActionMapping to only that single method. But the second WCF service I've got has two methods and now BizTalk doesn't know how to route my message. I've read everywhere that you need to set BTS.Operation in a custom pipeline to get it to work. But I've searched all over the place for a tutorial or example on how to do this.
I've been trying to implement the IBaseComponent, IComponentUI, IComponent and IPersistPropertyBag interfaces to do this. Am I going in the right direction or I'm I way off? Can anyone point me to an example or better yet show me how to do this?

The easiest way to get started writing a custom pipeline component is to use the BizTalk Server Pipeline Component Wizard; it will generate all the boilerplate for you. I've also got several custom pipeline components you can use as an example, a few that are very close to what you need (i.e. a component that just sets a custom message property) can be seen here.
As for setting the property, all you need to do is call message.Context.Write/Promote and pass in the namespace and name of the property, in this case those would be "http://schemas.microsoft.com/BizTalk/2003/system-properties" and "Operation" respectively.

Related

Register instance into builder from NServiceBus behaviour

I have a web api which sends commands to endpoints. I've created message a mutator which adds a custom header with a serialized IAuthenticationInformation instance.
What I need to do in the receiving endpoints is intercept this header (presumably in a Behavior), deserialize it into an IAuthenticationInformation and register it into the child container which will build the handlers to return it when requested.
I've got everything to the point of registering the instance into the container. The problem is that the context.Builder doesn't provide any Register operation.
How can I achieve this?
Notes:
I'm using v6 (I found a way of doing this in v5 using the PipelineExecutor, but this doesn't seem to work any more).
I'm using Unity, but I'd prefer a container independent solution
This issue seems very common to me, as I need this for a couple of other scenarios (i.e registering a unit of work with a given db connection), so I don't understand why is so difficult to find a solution. Should I be looking at another approach?
What you are doing is a variation of the Appending username using headers sample.
Add the UnityContainer as a constructor dependency in the IncomingMessageBehavior.
This will give you a child container to register your instance with.

Connecting an IObservableVector<T> to a WinJS ListView

We are developing a Metro-style app in C++ and JavaScript. The C++ side provides us with IObservableVector<T> instances. The JavaScript side uses the WinJS.UI.ListView control.
List views are normally hooked up to WinJS.UI.IListDataSource instances. Most typically, one takes a WinJS.Binding.List and uses its dataSource property.
However, it seems very natural to want to hook up an IObservableVector<T> to the list view. Is there any way to do this? For example, is there any adapter for turning IObservableVector<T>s into Lists or IListDataSources?
One route we could go down is to write our own custom WinJS.UI.IListDataAdapter implementation that hooks up to an IObservableVector<T>, then go through the whole game with the poorly-documented WinJS.UI.VirtualizedDataSource and so on. But, has anyone done this already? It seems like it should be in the framework.
WinJS 1.0 doesn't support the WinRT change notification interfaces (INotifyPropertyChanged, IObservableVector). If you want to hook them together, you'll need to write an adapter/data source.
Based on #Chris Tavares's helpful, if discouraging, response, I wrote such an adapter:
https://github.com/NobleJS/WinningJS/blob/master/lib/ObservableVectorDataSource.js
It is currently read-only (so you cannot update the data source and expect changes to propagate to the observable vector), but works great in our app.

VirtualPathUtility.ToAbsolute() VS. Url.Content()

I have been working in an MVC project, and have seen both of these used. I was wondering what the difference between them is? Is it incorrect to use one over the other? My understanding is that I should be using Url.Content(), but VirtualPathUtility.ToAbsolute() seems to be working as well.
Url.Content() is an utility method part of MVC. Being there to uniformize and centralize utility classes I guess.
VirtualPathUtility.ToAbsolute() is a .NET Framework method. Maybe the MVC one is using it, we would have to check the source...
Hope the helps
If you are doing this conversion within a Controller, then I'd favour VirtualParthUtility.ToAbsolute() over Url.Content().
The benefit comes when you want to unit test the controller actions. Rather than call it directly though, I'd define an interface IPathUtilities, say, with one implementation using VirtualPathUtility methods for the live site, and another using some sort of mock when testing.
If you call VirtualPathUtility directly, then you won't be able to test the action method (you might have thought some clever mocking of HttpContext would get round this, but having tried this myself I couldn't find a way to do it).

Using Web Services in the Flex Mate Framework

I am currently trying to use the "Invocation tags" of Mate to call my web services and delegate the WS-responses to my fault/result handlers.
I want to use the generated proxies, provided by the Flex Builder, and not the plain <WebService> or <WebServiceInvoker> tags.
I actually failed using several techniques:
<WebServiceInvoker> does not work with the generated proxies.
<AsyncMethodInvoker> needs some complicated successType that I could not get to work with the WS-calls. And defining the events seems redundant to me. I want it simple and easy to read, the code will be touched by other people than me!
<MethodInvoker> can't use instances, and it also can't handle the proxies' AsyncToken
<DelegateInvoker> Looked fine at first. It calls the service but doesn't fire valid result events (infinite busy cursor). Even though i can successfully bind to the XYZ_lastResult of the WS-proxies, and a WS-call results in getting valid data from the WS-backend, the <faultHandlers> and <resulthandlers> are not executed. There is some solution for the DelegateInvoker that changes code in the generated proxies, which i definately do not want to do!
So here is my question: Is there a simple(!) way of using default Flexbuilder generated proxies with the Mate Invocation tags?
It appears that your request is not that uncommon to Mate. Check out this couple of threads in their forum:
http://mate.asfusion.com/forums/topic.php?id=424
http://mate.asfusion.com/forums/topic.php?id=421
The solution is to modify some bits of the auto-generated code... which in a way ruins the whole point of using code generation.

How to catch all Exceptions from a WebService?

I have a Web Reference to a remote Web Service, which is called in several different classes. I'd like to catch all exceptions coming from this Web Service only.
How can I do that (for example extending it's base, auto generated class) without interfering and modifying all upper level code?
You can't, and why do you want to? It's almost always a mistake to "catch all exceptions" or "handle all exceptions". What are you trying to accomplish?
I'd suggest you log it on the server, not the client.
What will you be doing when you hide the exception from the upper layers? Pretending it didn't happen?
It might make sense to wrap the SoapException in one of your own. Maybe. That's only because SoapException is so specific to web services. In this case, yes, you need to wrap every call in a try/catch. The best way to do this would be in a facade class, which could also have the common code for wrapping the SoapException or translating it into one of your own.
Still, unless you're ready to take control of the code generation, you'll wind up doing this by hand.

Resources