public int openChannel(
@WebParam(name="targetWSURI", mode=WebParam.Mode.IN)String targetWSURI,
@WebParam(name="negotiatedMimeTypes", mode=WebParam.Mode.INOUT) Holder<List<String>> negotiatedMimeTypes,
@WebParam(name="negotiatedParams", mode=WebParam.Mode.INOUT) Holder<List<String>> negotiatedParams)
throws ServiceChannelException {
final ChannelContext serviceChannelContext = getChannelContext();
final ServerConnectionSession connectionSession = (ServerConnectionSession) serviceChannelContext.getConnectionSession();
final WSTCPAdapterRegistry adapterRegistry = getAdapterRegistry();
final WSTCPURI tcpURI = WSTCPURI.parse(targetWSURI);
final TCPAdapter adapter = adapterRegistry.getTarget(tcpURI);
if (adapter == null) throw new ServiceChannelException(ServiceChannelErrorCode.UNKNOWN_ENDPOINT_ADDRESS, MessagesMessages.WSTCP_0034_WS_ENDPOINT_NOT_FOUND(targetWSURI));
final BindingUtils.NegotiatedBindingContent serviceSupportedContent =
BindingUtils.getNegotiatedContentTypesAndParams(adapter.getEndpoint().getBinding());
negotiatedMimeTypes.value.retainAll(serviceSupportedContent.negotiatedMimeTypes);
if (negotiatedMimeTypes.value.isEmpty()) {
throw new ServiceChannelException(ServiceChannelErrorCode.CONTENT_NEGOTIATION_FAILED, MessagesMessages.WSTCP_0033_CONTENT_NEGOTIATION_FAILED(targetWSURI, serviceSupportedContent.negotiatedMimeTypes));
}
negotiatedParams.value.retainAll(serviceSupportedContent.negotiatedParams);
int channelId = connectionSession.getNextAvailChannelId();
ChannelSettings channelSettings = new ChannelSettings(negotiatedMimeTypes.value, negotiatedParams.value, channelId, adapter.getEndpoint().getServiceName(), tcpURI);
final ChannelContext openedChannelContext = new ChannelContext(connectionSession, channelSettings);
final SOAPVersion soapVersion = adapter.getEndpoint().getBinding().getSOAPVersion();
final Codec defaultCodec = adapter.getEndpoint().createCodec();
ChannelContext.configureCodec(openedChannelContext, soapVersion, defaultCodec);
connectionSession.registerChannel(openedChannelContext);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1141_SOAPTCP_CHANNEL_OPEN(connectionSession.hashCode(), openedChannelContext.getChannelId(), targetWSURI));
}
return channelId;
}