JSONCodec.globalMapValuePattern : Pattern.compile(jsonwebService.listMapValue()));
//
Map<String,Object> operationParameters = (Map<String, Object>) invocationProperties.remove(JSONCodec.JSON_MAP_KEY);
WSJSONPopulator jsonPopulator = new WSJSONPopulator((Pattern)invocationProperties.get(JSONCodec.globalMapKeyPattern_KEY),
(Pattern)invocationProperties.get(JSONCodec.globalMapValuePattern_KEY),JSONCodec.dateFormat,
codec.getCustomSerializer()
,(DebugTrace)invocationProperties.get(JSONCodec.TRACE));
Object[] parameterObjects = new Object[operation.getInParts().size()];
Class<?>[] parameterTypes = seiMethod.getParameterTypes();// This parameter types not trustable in case of HOLDER
for(Map.Entry<String, WSDLPart> part : operation.getInParts().entrySet()){
Class<?> parameterType;
if(context.getGlobalType(part.getValue().getDescriptor().name()) != null)
parameterType = context.getGlobalType(part.getValue().getDescriptor().name()).jaxbType;
else
/*
* This parameter types not trustable in case of HOLDER
* We can't find it in global type once user extend simple type and use it as method parameter.
* E.g String255 extended from String
*/
parameterType = parameterTypes[part.getValue().getIndex()];
if(!operationParameters.containsKey(part.getKey())){
return new JSONMessage(null, operation, operationParameters, jsonPopulator);
//throw new RuntimeException(String.format("Request parameter %s can't be null. B.P 1.1 vilation", part.getKey()));
}
Object val = null;
if(!WSJSONPopulator.isJSONPrimitive(parameterType)){
val = jsonPopulator.populateObject(jsonPopulator.getNewInstance(parameterType),
(Map<String,Object>)operationParameters.get(part.getKey()),jsonwebService,
(List<MIMEPart>) invocationProperties.get(JSONCodec.MIME_ATTACHMENTS));
} else {
val = jsonPopulator.convert(parameterType, null, operationParameters.get(part.getKey()),
seiMethod != null ? seiMethod.getAnnotation(JSONWebService.class) : null, null);
}
parameterObjects[part.getValue().getIndex()] = val;
}
// TODO find better way with out using JavaMethodImpl
List<ParameterImpl> requestParameters = ((JavaMethodImpl)javaMethod).getRequestParameters();
List<ParameterImpl> responseParameters = ((JavaMethodImpl)javaMethod).getResponseParameters();
invocationProperties.put(JSONEncoder.RESPONSEPARAMETERS, responseParameters);
if(operation instanceof WSDLBoundOperationImpl && ((WSDLBoundOperationImpl)operation).getOutputMimeTypes().size() > 0){
// Use only one in case of multipart use attachment
String mimeType = String.valueOf(((WSDLBoundOperationImpl)operation).getOutputMimeTypes().values().toArray()[0]);
for (Encoder handler : ServiceFinder.find(Encoder.class)) {
if(mimeType.equals(handler.mimeContent())){
invocationProperties.put(JSONCodec.ENCODER, handler);
break;
}
}
}
if(requestParameters != null && requestParameters.size() == 1){
ParameterImpl parameter = requestParameters.get(0);
if(parameter.isWrapperStyle()){
// RPC literal
List<ParameterImpl> childParameters = ((WrapperParameter)parameter).getWrapperChildren();
if(parameterObjects.length != childParameters.size())
throw new RuntimeException("Invalid count of parameters");
Object obj = null;
if(style == Style.RPC){
CompositeStructure cs = new CompositeStructure();
cs.values = parameterObjects;
cs.bridges = new Bridge[childParameters.size()];
for(ParameterImpl parameterChild : childParameters){
cs.bridges[parameterChild.getIndex()] = parameterChild.getBridge();
}
obj = cs;
}else{
Class<?> type = (Class<?>)parameter.getBridge().getTypeReference().type;
obj = jsonPopulator.getNewInstance(type);
for(ParameterImpl parameterChild : childParameters){
type.getField(parameterChild.getPartName()).set(obj,
parameterObjects[parameterChild.getIndex()]);
}
}