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()]);
}
}
return JAXBMessage.create(parameter.getBridge(), obj, this.codec.soapVersion);
}else{
// BARE
return new JSONMessage(null, operation, operationParameters,jsonPopulator);
}
}else{
return new JSONMessage(null, operation, operationParameters,jsonPopulator);
}
}else{
Message message = packet.getMessage();
if(message == null){
throw new RuntimeException("Null response message");
}
List<ParameterImpl> responseParameters = (List<ParameterImpl>) invocationProperties.remove(JSONEncoder.RESPONSEPARAMETERS);
Map<String,Object> responseParametersMap = new HashMap<String, Object>();
if(CAN_HANDLE_RESPONE && message instanceof JAXBMessage){
if(style == Style.RPC ){
Object jaxbObject = jaxbObjectAccessor.get(message);
if(jaxbObject instanceof com.sun.xml.bind.api.CompositeStructure){
com.sun.xml.bind.api.CompositeStructure responseWraper = (com.sun.xml.bind.api.CompositeStructure)jaxbObject;
if(responseWraper != null){
for(int index = 0; index < responseWraper.bridges.length; index++){
responseParametersMap.put(responseWraper.bridges[index].getTypeReference().tagName.getLocalPart(),
responseWraper.values[index]);
}
}
}else{
responseParametersMap.put(message.getPayloadLocalPart(), jaxbObject);
}
}else{
// Docunemnt
Object object = jaxbObjectAccessor.get(message);
for(Field field : object.getClass().getFields()){
responseParametersMap.put(field.getName(), field.get(object));
}
}
} else if(responseParameters != null && responseParameters.size() == 1){
// object deserialized. might perform bad.
ParameterImpl parameter = responseParameters.get(0);
Iterator<Node> paramBody = message.readAsSOAPMessage().getSOAPBody().getChildElements(parameter.getName());
if(paramBody.hasNext()){
Element responseElm = (Element)paramBody.next();
if(parameter.isWrapperStyle()){
List<ParameterImpl> children = ((WrapperParameter)parameter).getWrapperChildren();
for(ParameterImpl param : children){
NodeList paramElm = responseElm.getElementsByTagNameNS(param.getName().getNamespaceURI(),
param.getPartName());
if(paramElm.getLength() == 1){
responseParametersMap.put(param.getPartName(),
param.getBridge().unmarshal(paramElm.item(0)));
}
}
}else{
responseParametersMap.put(parameter.getPartName(),
parameter.getBridge().unmarshal(responseElm));
}
}
}
invocationProperties.put(JSONCodec.JSON_MAP_KEY, responseParametersMap);
return message;