Package com.jaxws.json

Examples of com.jaxws.json.JSONMessage


           * 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()]);
            }
          }
          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");
View Full Code Here

TOP

Related Classes of com.jaxws.json.JSONMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.