How can I access context property (incoming file name) in transformation (custom xslt)? - biztalk

Many historical posts about BizTalk Context Accessor (CodePlex), but all links are broken. Is there a state-of-the-art context accessor functoid / component to be used today? Or, is there any other way like creating helper class or something like it?
My aim is to add file name (without path) into the destination message in a map using Custom XSLT. No existing orchestration, only picking up a file and running a map to transform message from source to destination format (that requires source file name added to it...).

I solved my problem (this time) using an orchestration where I can access the context of the incoming message easily, and after mapping, inject/update the outgoing message with the file name.
I had one additional problem to solve that helped me accept using orchestration as solution this time. Two flies in one stroke.
(Problem was - note to self - I wanted to reuse destination schema in another debatching scenario, i.e. it was a envelope schema. Funny thing, BizTalk was not able to resolve body content schema if map was run in receive port. However, running map inside an orchestration, it was able to resolve the body content schema and mapping to envelope schema as destination worked.)

An alternative to the Context Accessor functiod is to use the BRE Pipeline Framework, and read the context property and inject it into the XML Payload.

Related

how to add file attribute in flow and state in corda

I am adding file as a attribute in flow and state in corda.It accept it but while making transaction it shows error."exception: Class "class java.io.File" is not on the whitelist or annotated with #CordaSerializable." like this.i add cordaSerialization annotation and implement Serializationwhitelist interface also.After deploying I got same error. Is it possible to add file as a attribute in flow and state in corda ??
If you are looking to use external methods by adding that code file to your code, you would need to add the annotation #CordaSerializable to the file. More details at https://docs.corda.net/docs/corda-os/4.5/serialization.html#whitelisting
But it looks like you are trying to use the IO methods to attach the file to your corDapp. If that is the case, you need to upload your file to your node. You can learn about how to upload the file by this sample: https://github.com/corda/samples-java/tree/master/Features/attachment-sendfile
or https://github.com/corda/samples-java/tree/master/Features/attachment-blacklist
(They are two way to do it.)

Custom Header with token in PASOE Business Class Entity with Web Service?

I have a PASOE Business Class Entity setup as a Web Service. I'm trying to determine how to create a custom header that will allow me to pass in a hashed token. Is this something that I need to upgrade to 11.7.4 for DOH(OpenEdge.Web.DataObject.DataObjectHandler)? Or is this something that I simply add into a method that's defined in the class? Apologies, for the lack of code to illustrate my situation, but I'm not sure where to begin.
If you're using a Business Entity with the web transport then you're using the DOH, and the below applies. If you're using the rest transport then you are not using the DOH, and are more limited in your choices.
There is doc available on the DOH at https://documentation.progress.com/output/oe117sp/index.html#page/gssp4/openedge-data-object-handler.html - it's for 11.7.4 but largely applies to all versions (that is, from 11.6.3+). This describes the JSON mapping file, which you'll need to create an override to the default, generated one.
If you want to use the header's value for all operations, then you may want to use one of the DOH's events. There's an example of event handlers at https://github.com/PeterJudge-PSC/http_samples/blob/master/web_handler/data_object_handler/DOHEventHandler.cls ; you will need to start that handler in a session startup procedure using new DOHEventHandler() (the way that code is written is that it makes itself a singleton).
You can now add handling code for the Invoking event which fires before the business logic is run.
If you want to pass the header value into the business logic you will need to
Copy the generated mapping file <service>.gen to a <service.map> , in the same folder. "gen" files are generated and will be overwritten by the tooling
In the .map file, add a new arg entry. This must be in the same order as the parameters to the BE's method.
The JSON should look something like the below. this will read the value of the header and pass it as an input parameter into the method.
{ "ablName": "<parameter_name>",
"ablType": "CHARACTER",
"ioMode": "INPUT",
"msgElem": {"type": "HEADER", "name": "<http-header-name>"}
}

Content based routing based on calculated property in BizTalk

I need to route a message based on a calculated property/field, but the same attribute/element does not exist in my outgoing schema. Is this possible?
Eg. Suppose I get an inbound message with containing employee name and date of birth. I calculate the age of the employee in orchestration or using functoid in maps. Now I want to send the message based on a condition on age, but the age property does not exist in the outgoing schema.
So Is content based routing possible on calculated properties?
You need a property schema with a property called "Age" and make sure you set this property as "MessageContextPropertyBase" by changing "Property Schema Base" from "Properties" of the node Age. Once you have the property schema then you can promote this property after your calculation either in Orchestration or in a custom receive pipeline component.
If you go with an Orchestration approach, then you need to create a correlation type with Age property and initialize the correlation on Send shape. Make sure you also set Age property on your outgoing message with Message_1(...). Deploy the property schema before using it in orchestration. if you are creating it in a different assembly then add a reference to it.
Or You can also create a custom pipeline component and promote the same Age property using Promote method in Execute method.
I'm pretty sure that promoted properties need to be part of the message. But you could always create a new message type which imports the original schema but with your new fields included and route based on that. Then you can map back to the original message type on an Outgoing map in your Send Port.
You will of course need to make sure that this new message passes through a pipeline with property promotion such as XMLReceive. So your Orch will need to handle that or alternatively, you could map to this new message in your Receive Port and do your routing before this Orch that you speak of. Difficult to say the best approach with knowing the specifics.
Yeah you can calculate the age and route the inbound message with a local variable.

Modifying a Biztalk message from custom code

Disclaimer: I am a complete biztalk newbie.
I need to be able to read and potentially edit 4 nodes in a biztalk message; preferably this needs to be done from a c# helper class as I am making a service call and also have unit tests written for this.
I already have this class wired up and it works with the XLANGMessage class, the problem I am running into is at this point in the orchestration the message is a Schema based type and doesn't seem to have any way for me to modify it.
I've done some reading and found a few ideas but have not been able to confirm if any of these can work from custom code.
1 write a map to transform the incoming message to the desired type
or
2 write something like this in your helper component to transform the message
public XmlDocument TransformMessage(XLANGMessage message)
Then pass the result document to a biztalk message in a message assignment shape.
responseMessage = xmlDocument;
You may get better performance if you pass streams instead of messages around.
You can pass messages into and out of C# helper classes easily. The simplest way is just to treat input parameters and return values as of type System.Xml.XmlDocument. The XLANG/s engine will safely cast back and forth from the XLANGMessage type to XmlDocument.
As you are essentially creating a "new" instance of the message (messages are immutable in BizTalk), the call to your helper class needs to be performed in a Message Assignment shape, with the outer Construct shape constructing the copy of your original message.
public static XmlDocument UpdateMyMessage(XmlDocument sourceMessage)
{
/* Do stuff to your Message here */
return sourceMessage;
}
A best-practice to consider is to declare all your C# helper methods as Static. This will avoid any issues with de/serialisation of your helper class during dehydration.
Are BizTalk messages immutable?
Generally speaking they are however, by creating a “corrective” orchestration and using a pass by reference option on the incoming message parameter, an existing message can be modified.

NLog - how to log all request information

The Nlog has some ASP.NET logging features (see the list of layout renderers), for example
${aspnet-request}
For log form item, I need to know name of item.
${aspnet-request:form=myVariable}
But how to log all from items, which hames in unknown?
For example
${aspnet-request:form}
I'd write my own LayoutRenderer, myself (in fact, just did something nearly identical, recently) - one of the best parts about NLog is how extensible the framework is. Depending on how you're doing configuration will determine how you reference/load your custom layoutrenderer, but the sky is really the limit in terms of what you can do.
Off the top of my head, you could take one of two approaches with a custom renderer: wrap/extend the existing asp request renderer and just proxy all calls, or get a hook to the request object the same way the nlog one does (which is tricky; it calls out to grab the COM instance, if memory serves).
The approach I took was to embed the NameValueCollection in the outgoing LogEventInfo object itself (in the properties dictionary), then use a custom layout renderer to extract that collection and render it.

Resources