Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
Java-SCA-1.4, Java-SCA-1.6, Java-SCA-2.0-M5
-
None
-
None
-
All
Description
The JSONP binding doesn't apply the JSON conversion correctly when an operation parameter is of array type. This is because the data type model is set incorrectly in the array case.
Both service and reference providers for the JSONP binding reset the binding interface contract databinding in order to enable JSON conversion using the JSON databinding using a line like....
contract.getInterface().resetDataBinding("JSON2x");
This works fine for ordinary parameters. What I didn't realize when I added this was that arrays are treated specially for some reason. There's code in InterfaceImpl which reads...
private void setDataBinding(DataType dataType, String dataBinding) {
if ("java:array".equals(dataType.getDataBinding()))
else
{ dataType.setDataBinding(dataBinding); }}
When you then reset a databinding on an operation that has a parameter of an array type you get something like....
Contract
Interface
Operation
InputDataType
Logical - databinding = java:array
Logical - databinding = JSON2x
This lead to the databinding code using the following transformations
Input2InputTransformer
Array2ArrayTransformer
Object2JSONTransformer
Where I would have expected
Contract
Interface
Operation
InputDataType
Logical - databinding = JSON2x
Logical - databinding = JSON2x
Input2InputTransformer
Object2JSONTransformer
I don't know what the advantage of keeping the array databinding in place. I guess the point is that the databinding code may not be able to cope with array transfomation but it can in the JSON case. So I need to extend the databinding resetting code to read...
contract.getInterface().resetDataBinding("JSON2x");
// force array types to map to JSON also
for (Operation operation : contract.getInterface().getOperations()){
DataType<List<DataType>> inputTypes = operation.getInputType();
for (DataType inputType : inputTypes.getLogical()){
if ("java:array".equals(inputType.getDataBinding()))
}
DataType outputType = operation.getOutputType();
if ("java:array".equals(outputType.getDataBinding()))
}
I may of course be missing something obvious to those who know about databinding.