biztalk xpath query in orchestration - xslt

I am using decide shape in orchestration and I receive 2 xml file.
and i have filter that file using xpatch because depend first node i have to process in different map. I use xpach statement to get find if the first node equal specific value if yes it will process if not it wil be send to second map.
how i should do that? I do not do it usually and try to find out how my statement should look
xpath(ACKSchema(name(/*))== CstmrPmtStsRpt;
How to check if xml file equal specific condition?
thanks

You can use the xpath query function to probe the value in the message, or set the value. The syntax for receiving a string value is
variable = xpath(BiztalkMessage,"string(xpath-query)");
To set a value in the message
xpath(BiztalkMessage,"xpath-query") = value
An easy way to locate the xpath you want to use is to open the schema in the Visual Studio BizTalk project, and select the node that will hold your value. Then look at the properties window and use the 'Instance Xpath' value (see this post for more details)
The xpath query can be a bit verbose, and depending on your situation you could shorten it (with a small loss of fidelity). If you are comparing a string value, you'll want to use the string function;
xpath(msgTestMessage,"string(//MyNode)") == "TestValue"
Without the xpath string function, you'll be receiving the equivalent of a nodeset, rather than the value.

You may not need to use the xpath and decide shape at all if your two xml files have different root nodes.
Using direct bound ports BizTalk can route your messages to the correct "subscriber" for you automatically. You drop the two input messages into the message box database. If you create one subscriber for each message type BizTalk will send the messages to the correct subscriber for you.
BizTalk uses the target namespace and the root node name to decide which subscriber gets which message.

Related

Get only MQ9 messages that belong to a group "2" in C++

I am trying to use IBM MQ client 9 with C++. I would like to read only messages that has group id '2'. I have tried everything but it just does not work. Can someone assist please?
I tried to set groupId and flag to match on group.
MQGET
gmoptions.setMatchOptions(MQMO_MATCH_GROUP_ID);
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
q->get(message, gmoptions);
MQPUT
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
ImqPutMessageOptions pmo;
pmo.setOptions(MQPMO_LOGICAL_ORDER);
pmo.setRecordFields(MQPMRF_GROUP_ID);
q->put(message, pmo);
mqget should be able to get all the msgs with groupId "2" but it does not. Though it can read the msg as soon as I remove setMatchOptions.
Basically, I want to use Group Id as filter where server instance 1 will read msgs only in group1 and server instance 2 will read msgs only in group 2 and so on, instead of creating separate queues for each server instance.
May be following can help me if group id is only for batching instead of filtering though not sure how to do 'Selection using the MQSUB and MQOPEN function calls' in C++
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q022990_.htm
Is there any C++ equivalent of MQSETMP ? I am unable to find any interface in ImqQueue or ImqObject that will let me set message property or selectionString.
I don't think you are going about this the right way.
IBM published a Java/MQ sample program to get messages in a group called GetGroup.java. You can find it here. You can use it as a model for your C++ program.
Basically, the code retrieves a message from the queue and then checks the messageFlags field if the message is part of a group.
if ((myMessage.messageFlags & CMQC.MQMF_MSG_IN_GROUP) == CMQC.MQMF_MSG_IN_GROUP)
If the message is part of the group then the code sets the matchOptions for matching on a group and retrieves all of the messages in the group.
Note: You will probably want to add logical order to the GMO options.
gmo.options |= CMQC.MQGMO_LOGICAL_ORDER;
Finally, what is this?
pmo.setRecordFields(MQPMRF_GROUP_ID);
That doesn't make any sense. You should be setting messageFlags field to MQMF_MSG_IN_GROUP.
You can use the concept of SELECTORS in IBM MQ. A message selector is a variable-length string used by an application to register its interest in only those messages that have properties that satisfy the Structured Query Language (SQL) query that the selection string represents.
A message selector is a concept that has been in the JMS specification for a long time. It
is a way of limiting the messages that are passed to an application to those that meet
certain criteria. Those criteria are based on the values of the message properties and only
the value of the message properties. It is important to understand that selection cannot be
based on any values of the message payload, only on the message property values.
In your case, the PUT application will have to put messages with populating the a certain topic string in MQMD or MQRFH2 header and using MQ Interface function calls, you should be able to pick the messages only with a certain value which in your case is GroupId value.
Below are few reference links to the concept:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q022990_.htm
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.wmq_v7/wmq/7.0/MQI/iea_330_wmqv7_API_3_Selectors.pdf ==> Pdf gets downloaded
To understand Message Properties => https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q022920_.htm

BizTalk Mapping supress empty attribute in the destination

I have a case in BizTalk where I want to map an "Attribute Node" which type is Date that can't be null or empty and to avoid problems I need to suppress in the destination transformation map when the source is null.
I followed this link to try the same thing that we do with Nodes but doesn't answer my problem.
https://social.technet.microsoft.com/Forums/security/en-US/4ab184e0-c978-429c-a80d-e869732de8a2/how-to-suppress-empty-nodes-in-biztalk-map?forum=biztalkgeneral
Anyone have an idea?
Thank you,
Roberto
Edited
The link didn't mentioned that the Logical String returns True or Nill depending on your source.
I've obliged to check if is empty and as well null
From the source, connect to a Length Functoid, then Greater Than 1 Functoid.
Connect the Greater Than Functoid to the target.
However you end up composing it, connecting a Functoid that returns a boolean is treated as a create yes/no regardless of any value also mapped.

BizTalk Mapping:Source record does not exists but need to map and pass default value

I have a source schema in which a particular record is optional and in the source message instance the record does not exist. I need to map this record to destination record, scenario goes like if the source record doesn't exist, need to map a default value 0 to destination nodes. and If it does exists , need to pass the source node values as it is (followed by few arithmetic operations).
I have tried using various combinations of functoids like logical existence followed by value mapping,record count ,string existence,etc. Also tried using c# within scripting functoid and also xslt , nothing works.its very tough to deal with mapping non existing records. I have several records on top of this record which are mapped just fine and they do exists. having trouble only with this one.No matter how many combination of c# and xslt code i write , it feels like scripting functoid will never accept a non existence record or node link. Mind you that this record if exists ,can repeat multiple times.
Using BizTalk2013r2.
If the record doesn't exist (record is not coming, not even as < record/>) you can use this simple combination of Functoids.
Link the record to Logical Existence, if exist it will be sent by the top Value Mapping. If doesn't exit the second condition will be true and the zero will be sent from the value mapping in the bottom.

BIRT - using multiple webservices to get the data

I am trying to generate a report using Eclipse BIRT report designer.
The scenario is this:
There are 2 web service data sources. There are 2 datasets for webservices 'WS1' and 'WS2' respectively.
The output element 'COUNTRYID' of one webservice 'WS1' would go as input for another webservice 'WS2'.
What I did:
Created a parameter COUNTRYID.
Created a dummy Computed Column in the dataset of the web service 'WS1' with the expression:
params["COUNTRYID"].value=row["COUNTRYID"]
Now the input parameters for the 'WS2' dataset is related to the global paramter 'COUNTRYID'.
When I run the report, I see that the global parameter contains the value from the 'WS1' output.
But the report does not display the values from the response of the web service 'WS2'
My questions:
How can I see, if the webservice got fired or not?
How can I see, if the webservice got fired with correct values ?
WS1 is not fired unless it is explicitely bound to a report element. Typically, to achieve this we apply following steps:
insert a data element at the beginning of the report body
turn the property visibility of this new element to false (or let it visible during testing)
bind it to the first dataset WS1
It will force a silent execution of WS1, and therefore this will populate your parameter COUNTRYID before WS2 runs.
However this approach would not work if:
WS2 dataset has to be used to populate selection items of a report parameter (which does not seem to be the case here)
If COUNTRYID parameter is used at render time. This point is much more annoying, if you need this parameter in chart expressions for example. If so, i would recommend to store WS1 in a report variable instead of (or why not in addition to) a report parameter. See this topic to see how to create a report variable.
You can initialize it at the same place you did for the report parameter with:
vars["COUNTRYID"]=row["COUNTRYID"];
and use it anywhere with
vars["COUNTRYID"];
Report variables are available from the palette of expressions editor :

Is there a table which holds all possible states of a determined work Item type in TFS?

I'm developing a Time Tracking system in TFS so we can control how much time is spent in each task. I'm doing it by checking changes in work items states, and recording the time between states.
I'm using WCF and TFS2010 alert subscription.
Then I noticed the State column in the WorkItem table holds a string, instead of an ID pointing to a State.
With that in mind, I noticed I would have to parse each state and check if it corresponds to some string. And then, some day, someone might want to change the State name. Then we're doomed.
But before I hardcore (or put in some random config.xml)... let me ask, is there a table which holds all possible states of a determined work Item type in TFS?
The states of work item types are stored in the process template files. You can export the work item type to an xml file using witadmin.exe and see the allowed values of the "State" in there.
Programmatically, you can use the Microsoft.TeamFoundation.WorkItemTracking.Client namespace to get the WorkItemType object of your work item type, look for the FieldDefinition object of the "State" in the FieldDefinitions property, then get the possible states from the AllowedValues property of FieldDefinition class.