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; }
private String getUpdatedClientConfigTemplate( CodeGenContext codeGenCtx, ClientConfigList clientCfgList) throws CodeGenFailedException { try { if (clientCfgList == null || clientCfgList.getClientConfig().size() == 0) { throw new CodeGenFailedException("The content of 'ClientConfigList' is empty."); } String contents = CodeGenUtil.getTemplateContent(CLIENT_CONFIG_TEMPLATE); ClientConfig clientConfig = clientCfgList.getClientConfig().get(0); contents = CodeGenConfigUtil.replaceTemplate( contents, CONFIG_GROUP_NAME, clientConfig.getGroup(), CONFIG_GROUP_NAME_ATTR); contents = CodeGenConfigUtil.replaceTemplate( contents, CONFIG_SERVICE_NAME, clientConfig.getServiceName(), CONFIG_SERVICE_NAME_ATTR); contents = CodeGenConfigUtil.replaceTemplate( contents, SERVICE_INT_NAME, clientConfig.getServiceInterfaceClassName(), SERVICE_INT_NAME_NODE); contents = CodeGenConfigUtil.replaceTemplate( contents, WSDL_LOCATION, clientConfig.getWsdlLocation(), WSDL_LOCATION_NODE); contents = CodeGenConfigUtil.replaceTemplate( contents, SERVICE_LOCATION, clientConfig.getServiceLocation(), SERVICE_LOCATION_NODE); ClientGroupConfig clientInstanceConfig = clientConfig.getClientInstanceConfig(); InvocationOptionConfig invocationOptions = null; PreferredTransportConfig preferredTransport = null; if (clientInstanceConfig != null) { invocationOptions = clientConfig.getClientInstanceConfig().getInvocationOptions(); } if (invocationOptions != null) { preferredTransport = invocationOptions.getPreferredTransport(); contents = CodeGenConfigUtil.replaceTemplate( contents, REQ_DATA_BINDING, invocationOptions.getRequestDataBinding(), REQ_DATA_BINDING_NODE); contents = CodeGenConfigUtil.replaceTemplate( contents, RESP_DATA_BINDING, invocationOptions.getResponseDataBinding(), RESP_DATA_BINDING_NODE); contents = CodeGenConfigUtil.replaceTemplate( contents, CONSUMER_ID, invocationOptions.getConsumerId(), CONSUMER_ID_NODE); contents = CodeGenConfigUtil.replaceTemplate( contents, INVOCATION_USE_CASE, invocationOptions.getInvocationUseCase(), INVOCATION_USE_CASE_NODE); } String transportName = null; if (preferredTransport != null) { transportName = preferredTransport.getName(); } contents = CodeGenConfigUtil.replaceTemplate( contents, PREFERRED_TRANSPORT_NAME, transportName, PREFERRED_TRANSPORT_NAME_ATTR); return contents; } catch (Throwable e) { throw new CodeGenFailedException( "Failed in retriveing the client config template " + CLIENT_CONFIG_TEMPLATE + e.getMessage(), e); } }