private ClientConfig createClientConfig(CodeGenContext codeGenCtx) {

    InputOptions inputOptions = codeGenCtx.getInputOptions();

    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroup(inputOptions.getClientCfgGroupName());
    // put serviceNametag in cc.xml only if pre 2.4 consumer
    if (codeGenCtx.getInputOptions().isServiceNameRequired())
      clientConfig.setServiceName(codeGenCtx.getServiceQName().toString());
    String svcInterfaceName =
        CodeGenUtil.toQualifiedClassName(codeGenCtx.getServiceInterfaceClassName());
    clientConfig.setServiceInterfaceClassName(svcInterfaceName);
    if (inputOptions.getSvcCodeGenDefType() == null) {
      clientConfig.setServiceLocation(inputOptions.getServiceLocation());
      clientConfig.setWsdlLocation(inputOptions.getWSDLLocation());
    } else {
      ServiceCodeGenDefType svcCodeGenDef = inputOptions.getSvcCodeGenDefType();
      clientConfig.setServiceLocation(svcCodeGenDef.getServiceInfo().getServiceLocation());
      clientConfig.setWsdlLocation(svcCodeGenDef.getServiceInfo().getWsdlLocation());
    }

    ClientGroupConfig clientGrpCfg = createClientGroupConfig(codeGenCtx);
    clientConfig.setClientInstanceConfig(clientGrpCfg);

    return clientConfig;
  }
  private InvocationOptionConfig defaultInvocationOptions(CodeGenContext codeGenCtx) {

    String prefDataBinding = "XML";
    InputOptions inputOptions = codeGenCtx.getInputOptions();

    InvocationOptionConfig defaultInvOptions = new InvocationOptionConfig();
    // if consumerId is set then it should be used else invocation Use
    if (!CodeGenUtil.isEmptyString(codeGenCtx.getInputOptions().getConsumerId()))
      defaultInvOptions.setConsumerId(codeGenCtx.getInputOptions().getConsumerId());
    else defaultInvOptions.setInvocationUseCase(codeGenCtx.getServiceAdminName() + "Client");

    PreferredTransportConfig prefTransportCfg = new PreferredTransportConfig();
    if (inputOptions.getServiceLocation() != null
        && inputOptions.getServiceLocation().startsWith("http")) {
      prefTransportCfg.setName(SOAConstants.TRANSPORT_HTTP_11);
    } else {
      prefTransportCfg.setName(SOAConstants.TRANSPORT_LOCAL);
    }

    // TransportOptionConfig transportOptCfg = new TransportOptionConfig();
    // transportOptCfg.setTransportName(CodeGenConstants.PREF_TRANSPORT_BINDING);
    // transportOptCfg.setNumRetries(Integer.valueOf(CodeGenConstants.NUM_OF_CONN_RETRIES));
    // prefTransportCfg.setOverrideOptions(transportOptCfg);

    defaultInvOptions.setPreferredTransport(prefTransportCfg);

    defaultInvOptions.setRequestDataBinding(prefDataBinding);
    defaultInvOptions.setResponseDataBinding(prefDataBinding);

    return defaultInvOptions;
  }
  public void generate(CodeGenContext codeGenCtx) throws CodeGenFailedException {

    ClientConfigList clientCfgList = null;

    InputOptions inputOptions = codeGenCtx.getInputOptions();
    ServiceCodeGenDefType svcCodeGenDef = inputOptions.getSvcCodeGenDefType();
    // If config info is specified in XML
    if (svcCodeGenDef != null
        && svcCodeGenDef.getConfigInfo() != null
        && svcCodeGenDef.getConfigInfo().getClientCfg() != null) {
      ConfigType configType = svcCodeGenDef.getConfigInfo();
      clientCfgList = configType.getClientCfg();
    } else {
      clientCfgList = createClientConfigList(codeGenCtx);
    }

    generateClientConfigXml(codeGenCtx, clientCfgList);
  }
  private void generateClientConfigXml(CodeGenContext codeGenCtx, ClientConfigList clientCfgList)
      throws CodeGenFailedException {

    Writer fileWriter = null;
    try {
      if (CodeGenUtil.isEmptyString(codeGenCtx.getClientName()))
        codeGenCtx.getInputOptions().setClientName(codeGenCtx.getServiceAdminName());
      String destFolderPath =
          CodeGenUtil.genDestFolderPath(
              codeGenCtx.getMetaSrcDestLocation(), getSuffixPath(codeGenCtx.getClientName()));
      if (!CodeGenUtil.isEmptyString(codeGenCtx.getInputOptions().getEnvironment())) {
        destFolderPath =
            destFolderPath
                + codeGenCtx.getInputOptions().getEnvironment()
                + File.separator
                + codeGenCtx.getServiceAdminName()
                + File.separator;
        destFolderPath = CodeGenUtil.toOSFilePath(destFolderPath);
      }

      String contents = getUpdatedClientConfigTemplate(codeGenCtx, clientCfgList);

      fileWriter = CodeGenUtil.getFileWriter(destFolderPath, CLIENT_CONFIG_FILE_NAME);
      fileWriter.write(contents);

      getLogger()
          .log(
              Level.INFO,
              "Successfully generated " + CLIENT_CONFIG_FILE_NAME + " under " + destFolderPath);

    } catch (Exception ex) {
      getLogger().log(Level.SEVERE, "Error " + ex.toString());
      throw new CodeGenFailedException("Failed to generate Client Config xml file", ex);
    } finally {
      CodeGenUtil.flushAndCloseQuietly(fileWriter);
    }
  }