Author |
Message
|
akil |
Posted: Tue Jul 29, 2014 12:40 am Post subject: IIB9: Mapping Node, Database Select |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I am using the Mapping node to select data from a table and return is as a XML. In case there is no data , I need to return a 404 (header only response).
Is this configurable in the mapping node ? Or do I write a compute note after the mapping node to do this? _________________ Regards |
|
Back to top |
|
 |
Simbu |
Posted: Tue Jul 29, 2014 3:23 pm Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
Yes, you can with the mapping node. if exists of your resultset, do your transformation else map to HTTPReplyHeader. Assign the value 404 to the HTTP StatusCode in the HTTPReplyHeader.you have to define the StatusCode in the schema and cast it in HTTPReplyHeader to perform the mapping. |
|
Back to top |
|
 |
Simbu |
Posted: Tue Jul 29, 2014 3:48 pm Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
You can also use LocalEnvironment tree to populate HTTPReplyCode in mapping node. |
|
Back to top |
|
 |
martinb |
Posted: Wed Jul 30, 2014 3:45 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Hi
In addition to the options from Simbu you can also cause a flow rollback from a Mapping node using the "fn:error" Transform.
So here you could again use If transform with condition of fn:exists / fn:count etc on the ResultSet and then in the "failure" case invoke the "fn:error" Transform.
Within the nested mapping use the fn:error noting a couple of key points:
(1) The fn:error transform requires input and output, although these are often really not used. You might want to provide some input that provides part of the erorr text.
(2) The fn:error function requires two parameters
- The first must be a valid QName data type, use a type cast, xs:<type> to provide this, eg xs:QName('Error')
- if you pick the fn:error function from the Mapper pick list you must use "add" action to get the second parameter, "description" for which you provide some string value. |
|
Back to top |
|
 |
akil |
Posted: Thu Nov 06, 2014 8:40 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Till now I had scenarios where I had simple cases where the mapping node was followed up by a reply so the LocalEnvironment method worked.
Now I am in between a flow and I need to throw an exception, I know from martins suggestion about fn:error, but I am unable to find documentation around it .. is there any? _________________ Regards |
|
Back to top |
|
 |
martinb |
Posted: Thu Nov 06, 2014 9:17 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
The Integration Bus documentation currently just sends you to the XPath 2.0 specification for details of the fn: Xpath functions you can utilize in Graphical Data Maps.
I personally find the "man page" style entries at http://www.xqueryfunctions.com more readily consumable, although there is always the odd time when the formal specification needs to be visited for the definitive answer.
Anyway when using fn:error in a Graphical Data Map please note the following:
- You'll find it in the "Diagnostic functions" category of the transform picker
- Ensure you wire it with both an input and output, it does not matter what output element you wire it to, just ensure you locate the transform inside the nested block of the map which will be entered when you want to "abort" the mapping.
So you might locate fn:error inside a If/Else nested map
- The fn:error function requires two parameters
- The first parameters must be a valid QName data type, use a type cast, xs:<type> to provide this, eg: xs:QName('Mapping Error')
- The second parameter, "description" allows you to provide some string value as part of the error message, eg: 'Invalid reason here'
- if you pick the fn:error function from the Mapper pick list you must use "add" action on it's properties page to get this required parameter.
With the example parameter values noted above the Mapping node would throw an exception which would include the nested BIP msgs as:
Code: |
BIP3947E: The map processing for QName ''{default}:ExampleUseOfFnError'' has failed, with the following details: ''Function: fn:error: data( fn:error(xs:QName('Mapping Error'),'Invalid reason here') )''.
BIP3949E: An error occurred during the processing of a message. The error message is ''IXJXE0443E: [ERR 0392] :ERROR; Invalid reason here
|
Hopefully this will get you going. |
|
Back to top |
|
 |
akil |
Posted: Thu Nov 06, 2014 11:09 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
Thank you, this helped and worked as you described.
Except for one minor point, if you could help in clarifying.
In the 'Add' Parameters, the toolkit lets me add add 'description' & 'error-object'.
Your post talked about description and if I use that it works fine.
What is the error-object parameter? And when is this to be used?
Also, is Error Number 3949 allocated for this, (in case i want to handle this in my code to handle these exceptions ?) _________________ Regards |
|
Back to top |
|
 |
martinb |
Posted: Tue Jun 02, 2015 1:32 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Correction and clarification for using fn:error in a Graphical Data Map :
- You'll find fn:error in the "Diagnostic functions" category of the transform picker
- Ensure you wire it with both an input and output, it does not matter what output element you wire it to, just ensure you locate the transform inside the nested block of the map which will be entered when you want to "abort" the mapping. For example inside an "if / else" nested map
- The fn:error function requires two parameters
- The first parameters must be a valid QName data type, use a type cast, xs:<type> to provide this, eg: xs:QName('ErrorThrowInMap')
- The second parameter, "description" allows you to provide some string value as part of the error message, eg: 'Invalid reason here'
- if you pick the fn:error function from the Mapper pick list you must use "add" action on it's properties page to get the required "description" parameter. You also then "remove" the unused error-object parameter.
- The exception raised by invoking fn:error is reported using BIP3947E. This BIP code BIP3947 is also used for other map execution "failures" |
|
Back to top |
|
 |
radusun |
Posted: Thu Jul 09, 2015 10:16 am Post subject: |
|
|
Newbie
Joined: 06 Dec 2014 Posts: 1
|
Hi martinb,
I followed your steps and it seems to work. But I cannot get rid of this annoying warning:
The error XPath function in the error((xs:QName('Booking')),'More than one Booking detected') XPath is not supported.
Do you have such a warning too?
If not, do you know a trick how to "make it right" so that the IIB Toolkit does not complain?
I like to have a clean environment and I am struggling to get rid / solve all the warnings (not just the errors ).
Thanks. |
|
Back to top |
|
 |
martinb |
Posted: Sat Jul 18, 2015 12:04 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Hi
I'm afraid the Graphical Data Mapper is incorrectly posting that warning on the valid usage of fn:error().
You will not be able to workaround it, you'd have to raise it via a PMR to get to your good working practice of maintaining a clean environment. |
|
Back to top |
|
 |
|