camel XPATH variable to XQuery element() convert problem - apache-camel

In Apache camel I need to extract a xml element and pass it to xquery as
element(), but i have strange error.
Any idea and suggesions are more than welcome!
Camel code:
from(SOAP_ENDPOINT_IN_URI + "&dataFormat=CXF_MESSAGE")
.setHeader("CMDRequest", XPathBuilder.xpath("//*[local-name() =
'CMDRequest']")
Xquery code:
declare variable $in.headers.CMDRequest as element() external ;
Error:
Caused by: net.sf.saxon.trans.XPathException: Required item type of value of variable $in.headers.GetDeltaCustomerRequest is element(); supplied value has item type Q{http://saxon.sf.net/java-type}com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList

It looks your xpath is returning a list of elements and not a single element. This could be fixed by by taking the first item of the array of CMDRequest's (assuming list is never empty):
.setHeader("CMDRequest", XPathBuilder.xpath("(//*[local-name()='CMDRequest'])[1]")

Related

template language function 'slice' expects its first parameter to be of type string in logicapps Variables

I have a requirement to slice "Dev" from below variable vmName in Azure logicapp
variable information :
Name : vmName
Type : String
Value : Dev-Testing-2
When i tried with below approach/expression :
slice(split(variables('dsvmName'),'-'),1)
error : The template language function 'slice' expects its first parameter to be of type string. The provided value is of type 'Array'. Please see https://aka.ms/logicexpressions#slice for usage details.'.
Try this (untested) ...
split(variables('dsvmName'),'-')?[0]
That will retrieve the first item in the array when you split it by a hyphen.
I have reproduced in my environment and got expected results and followed below process:
Firstly, I have taken a http trigger and then initialized as below:
Then, again I initialized as below:
indexOf(variables('vmName'), '-')
Then again initialized as below to get output:
substring(variables('vmName'),0, int(variables('emo')))
Output:

Jmeter tool create request..cannot handle array parameters and dynamically created parameters

I'm having 2 issues when trying to do the create api requests using the jmeter tool
1). How to handle an array parameter. "Versions": "$[Versions]"
getting the following error message
{"timestamp":"2020-02-14T07:18:33.720+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize instance of
java.util.ArrayList<java.lang.Object> out of VALUE_STRING token;
nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of java.util.ArrayList<java.lang.Object> out of
VALUE_STRING token\n at [Source: (PushbackInputStream); line: 15,
column: 22]
2). how to handle dynamically created time stamp parameter createtime: "${createtime}"
getting the following error message
{"timestamp":"2020-02-14T07:17:58.942+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize value of type
java.time.OffsetDateTime from String \"${factoryCompleteTime}\":
Failed to deserialize java.time.OffsetDateTime:
(java.time.format.DateTimeParseException) Text
'${factoryCompleteTime}' could not be parsed at index 0; nested
exception is
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot
deserialize value of type java.time.OffsetDateTime from String
\"${factoryCompleteTime}\": Failed to deserialize
java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '${factoryCompleteTime}' could not be parsed at index 0\n at
[Source: (PushbackInputStream); line: 15, column: 24]
My json body looks like this.
"Versions": "$[Versions]",
"createtime": "${createtime}"
I think you should pass this Versions a little bit differently, for example if it should be a JSON Array it should look like:
"Versions": [${Versions}],
or
"Versions": ${Versions},
It appears that your ${factoryCompleteTime} variable doesn't have a value so it has been replaced by the default placeholder. Use Debug Sampler and View Results Tree listener combination in order to check the variable value, it should be in format of the OffsetDateTime to wit something like: 2007-12-03T10:15:30+01:00

Parameterize() must be of the type array, string given in Laravel 5.2

i am using laravel 5.2 and trying to update records using whereIn('id',[1,2]) but when i try to pass a json value [1,2] to it , i returns
parameterize() must be of the type array, string given. I am mentioning my code below.
$load_id=json_encode($request->chk_load,JSON_NUMERIC_CHECK); // it returns [1,2]
Load::whereIn('id',$load_id)->update(array('status'=>3));
What should i do to fix this error. ?
seems json_encode($request->chk_load,JSON_NUMERIC_CHECK);
returns json string and not an array..
can you elaboarate $request->chk_load is what kind of data it is?

How to connect attributes from list when Maya does not find those attributes?

What I am looking to do is batch connect attributes from object A to object B. Just the transform attributes, so, I did this:
import maya.cmds as mc
sel = mc.ls(sl=True)
mc.connectAttr(sel[0]+'.t', sel[1]+'.t')
mc.connectAttr(sel[0]+'.r', sel[1]+'.r')
mc.connectAttr(sel[0]+'.s', sel[1]+'.s')
And then I thought it would be more clever if I created a list containing (translate, rotate and scale) and just iterate over that list instead of specifying ".t", ".r" and ".s".
So I did this:
import maya.cmds as mc
sel = mc.ls(sl=True)
attributes = ['.t', '.r', '.s']
for attr in attributes :
mc.connectAttr(sel[0].attr, sel[1].attr)
...to which the console says
# Error: AttributeError: file <maya console> line 7: 'unicode' object has no attribute 'attr' #
I did some searching, but it didn’t help me understand. Can someone explain why this is happening, and how I can achieve the desired results?
Your last line has to be:
mc.connectAttr(sel[0]+attr, sel[1]+attr)
You are using . as if it were the string concatenation error in Python, while + is.
Instead . is the attribute operator, which explains your error¹. When Python tries to interpret sel[0].attr, it first notes that sel[0] is a unicode object and then tries to get the attribute attr from that object. This attribute has nothing to do with the attr from your loop and in particular doesn’t exist. Hence the error message you got.
¹ Every object in Python has some attributes, which you can access with that syntax and which depend on the type object. To get familiar with this try:
a = 42
print(a.numerator)
print(a.denominator)
print(a.wrzlprmft)
# Raises AttributeError. This is what happened to you.
print(denominator)
# Raises NameError.
# This demonstrates that denominator is only defined as an attribute of a.

Error with ibatis sql iterate

I'm using ibatis + DWR , but when i pass a map to ibatis i will get an error as below:
Cause: com.ibatis.sqlmap.client.SqlMapException: ParameterObject or
property was not a Collection, Array or Iterator.
here is my sql:
<update id="updateDarenFlagByUserTagIDs" parameterClass="java.util.Map">
update system_usertag
set isdaren = 1
where uid = #uid#
<isNotEmpty prepend=" AND " property="utidlist">
and utid in
<iterate open="(" close=")" conjunction="," property="utidlist">
#utidlist[]#
</iterate>
</isNotEmpty>
</update>
and here in the DWR part, i passed a map as below:
{'uid':uid, 'utidlist':utidlist}
Any ideas on this error?
I have answered the exact same question in the following post https://stackoverflow.com/questions/18997883/malformed-url-exception-in-ibatis/19025819#19025819 do make reference to it. The solution to your problem is very simple, ensure that the argument nested in your iterate tag <iterate></iterate> which in your case is "utidlist" is indeed a list/collection and nothing but a list. The cause of this error is that your iterable property "utidlist" isn't a list. If you can get it to be a list and not a flat value you'll just be fine.
Just in case you can still get it to work you may also want to paste a full stack of your logs so that you can see what is going wrong.

Resources