Biztalk Distinguished field issue - biztalk

I'm passing a message in biztalk that is resulting in the following suspended message:
Inner exception: A failure occurred while evaluating the distinguished
field MessageStatus against the message part data. The message part
data does not contain at least one of the nodes specified by the XPath
expression (listed below) that corresponds to the distinguished field.
The cause for this error may be that the message part data has not
been initialized or that the message part data does not conform to the
message
In my orchestration I'm using a map that maps an ID called textID to the textID field in my constructed message "MessageAttempt". I also have a field called MessageStatus with the value set to "Nothing" not to be confused with .
After my map I use a message assignment shape to set the MessageAttempt.MessageStatus element to "Attempted" with the following code:
Message_MessageAttempt.MessageStatus = var_Attempt;
I been trying to figure this out all day. I have a similar ConstructedMessage/Transform/Assignment shape on a different branch in my orchestration set up the same and works just fine. I'm not sure what I could be missing.

The XPath functoin can't find the element. There are two possible reasons for this.
The element doesn't exist. If it doesn't exist, you have to create it first. You can do this In the map by setting its value property to <empty>, or using an empty String Concatenate functoid with its output into that node.
You should be able to verify this by going into the group hub, opening the suspended message, and viewing the message part. You'll find that it doesn't contain the node the XPath refers to.
The namespaces in the message are not qualified properly. XPath in orchestrations runs into issues if you don't use namespace prefixes for the message and just rely on the default/empty xmlns.

Related

OXygen Implementation of XQuery: Why Can't Path Expressions Return Attribute Values Directly?

Previous Stack questions indicate that in certain implementations of XQuery, returning attributes directly from a path expression (e.g. `$doc//#name') fails to display results and yields runtime errors:
Can't select XML attributes with Oxygen XQuery implementation; Oxygen XPath emits result
XQuery unable to select attribute
While attribute values can be returned using the string() or data() functions, I'm still confused as to why this limitation exists at all. The former link suggests that it is indeed the OXygen IDE itself, independent of the XQuery processor. However, when I try to return attributes directly I get the following runtime error message:
error: Failed to invoke method retrieveFirstChunk in class org.exist.xmlrpc.RpcConnection: org.xml.sax.SAXException:
Error SENR0001: attribute 'notBefore' has no parent element
Since this error message is from the processor, could the type of processor play a role? I'm using eXist-db as my data source and processor.
I don't know the specifics of the particular products involved, but the basic situation is that XQuery can return an attribute or sequence of attributes, but the standard XQuery 1.0 serialization methods can't display the value. For example a query like //#id will select a sequence of attributes all named "id" and there is no way of serializing this as XML. The "adaptive" serialization method was introduced in XQuery 3.1 largely as a response to this problem: it's designed to display the results in human-readable form, not to output well-formed XML.

Can you map a fixed value using the standard BizTalk mapper

Normally, I create my BizTalk mappings in the XSL. Today I was playing around with the mapper but I am failing to do the most basic thing and googling it fails me (I find unrelated questions or the basic way to do it in XSL)
The question is simple though, I want to use the BizTalk mapper (btm file) to map one element to another and fill a second element with a fixed value.
Looking at the functoids, I have a date functoid which gets today's date but nothing to just type some text and map it.
Am I missing something very obvious?
The "built in" way to do this is to set the Value property on the destination node in the map (you can also use this property to desginate that an empty node should be created for this destination node). Unfortunately, this method offers no visual representation that the node is being set this way, except that it will prevent you from linking other nodes/functoids to that destination node. This may lead future devs (or your future self) to think the node isn't being set, or be confused as to why it's being set when it has no inputs.
To get around this, I've frequently used either a String Concatenate functoid (with the fixed value as the only parameter, manually typed in) or a Value Mapping functoid (set "true" as the first parameter and the fixed value as the second parameter). This offers a few benefits:
Visually shows that node is being set by the map
Allows you to set a meaningful label and/or comment on the functoid to denote why you're setting that value.

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.

message data property <promoted property> in correlation <correlation> does not exist in message <messagename>

When trying to compile my orchestration that contains a correlation set I get the following error:
message data property <promoted property> in correlation <correlation> does not exist in message <messagename>
The Orchestration references a dll which contains the HL7v2 schema where the promoted property DOES exist, yet for whatever reason the orchestration/correlation set can't see it during compilation and the project won't compile due to the above stated error.
Details:
in the Orchestration view, the Correlation Type and Correlation Set is all setup successfully.
In the Correlation Properties of my Correlation Type I am able to browse to and see the reference to the promoted field and select it successfully.
I've been removing/re-adding the dll reference every time to ensure it's not a stale reference
I've been checking the GAC and the dll is being updated when I re-compile the Schema
Tried changing namespaces on the Property Schema to custom and default and back and still no help.
I'm wondering now
does the schema containing the promoted property have to be in the same project as the orchestration?
Is there something special about correlations and the HL7 schemas (all the correlation examples are on a 'Hello World' level, so it doesn't help much)
anything else I can try to get this work, we need to correlate 2 messages using a couple promoted properties.
You cannot use Properties derived from MessageDataPropertyBase for Subscriptions, which is what the Correlation set would create.
Change "Property Schema Base" to MessageContextPropertyBase. This on the property element in the Property Schema.
Why does it show up on the list when you create the Correlation Type? An oversight (bug) in that property list.

ASP.NET - displaying business layer errors in the presentation layer

Currently in the ASP.NET application I'm developing, basic validations (ie required fields) are being done in the Presentation Layer, using Validators and a ValidationSummary. This is working great for me specifically since the ValidationSummary will display multiple error messages (assuming multiple Validators are set to invalid).
I also have some validations being done in the business layer - due to their complexity (and data service layer reliance) I'd rather not keep them in the presentation layer. However, I'm not sure the best way to send these back to the presentation layer for display to the user. My initial consideration is to send back a List<string> with failed validation messages and then dynamically create a CustomValidator control (since apparently you can only bind one error message to one Validator control) for each error to show in the ValidationSummary when there are any.
I'm assuming I'm not the first one to come across this issue, so I'm wondering if anyone has any suggestions on this.
Thanks!
There are essentially two ways to do this: either by passing back an error code/object from your business layer, or throw out an exception. You can also combine both.
For an example, you can take a look SqlException class. When you send a SQL to SQL Server, it runs a query parser to parse your SQL first. If it sees syntax error, then it will throw out a SqlException and terminate the query. There may be multiple syntax errors in your query. So SqlExeption class has an Errors property that contains a list of errors. You can then enumerate through that list in your presentation layer to format your error message, probably with a CustomValidator.
You can also simply just return the error list without throwing an exception. For example, you can have your function to return a List in case at least one error occurred and return null in case the call was successful. Or you can pass List as an argument into your function. They are all fine, it all depends on which way you feel is more convenient. The advantage of throwing out an exception is it unwinds multiple call frames immediately, so you don’t have to check return value on every level. For example, if function A calls function B , B calls function C, C sees something wrong, then if let C to return an error object (or error code), then B has to have code to check whether C returned an error and pass that error code/value back, A have to check it as well ---- you need to check it on every level. On the other hand, if you just let C to throw an exception, then the code goes straight to the exception handler. You don’t have check return values on every level.

Resources