/** * Make sure that the endpoints created by the factory has a name * * @param epConfig OMElement containing the endpoint configuration. * @param anonymousEndpoint false if the endpoint has a name. true otherwise. * @param properties bag of properties to pass in any information to the factory * @return Endpoint implementation for the given configuration. */ private Endpoint createEndpointWithName( OMElement epConfig, boolean anonymousEndpoint, Properties properties) { Endpoint ep = createEndpoint(epConfig, anonymousEndpoint, properties); OMElement descriptionElem = epConfig.getFirstChildWithName(DESCRIPTION_Q); if (descriptionElem != null) { ep.setDescription(descriptionElem.getText()); } // if the endpoint doesn't have a name we will generate a unique name. if (anonymousEndpoint && ep.getName() == null) { String uuid = UIDGenerator.generateUID(); uuid = uuid.replace(':', '_'); ep.setName(ENDPOINT_NAME_PREFIX + uuid); if (ep instanceof AbstractEndpoint) { ((AbstractEndpoint) ep).setAnonymous(true); } } OMAttribute onFaultAtt = epConfig.getAttribute(ON_FAULT_Q); if (onFaultAtt != null) { ep.setErrorHandler(onFaultAtt.getAttributeValue()); } return ep; }
public String getContentID() { if (contentID == null) { contentID = UIDGenerator.generateContentId(); } return this.contentID; }
/** * Create an Axis2 message context for the given http request. The request may be in the process * of being streamed * * @param request the http request to be used to create the corresponding Axis2 message context * @return the Axis2 message context created */ private MessageContext createMessageContext(HttpRequest request) { MessageContext msgContext = new MessageContext(); msgContext.setMessageID(UIDGenerator.generateURNString()); // There is a discrepency in what I thought, Axis2 spawns a new threads to // send a message if this is TRUE - and I want it to be the other way msgContext.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.FALSE); msgContext.setConfigurationContext(cfgCtx); if ("https".equalsIgnoreCase(schemeName)) { msgContext.setTransportOut( cfgCtx.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_HTTPS)); msgContext.setTransportIn( cfgCtx.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTPS)); msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTPS); SSLIOSession session = (SSLIOSession) (conn.getContext()).getAttribute("SSL_SESSION"); msgContext.setProperty( "ssl.client.auth.cert.X509", session.getAttribute("ssl.client.auth.cert.X509")); } else { msgContext.setTransportOut( cfgCtx.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_HTTP)); msgContext.setTransportIn( cfgCtx.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTP)); msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP); } msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, this); // the following statement causes the soap session services to be failing - ruwan // msgContext.setServiceGroupContextId(UUIDGenerator.getUUID()); msgContext.setServerSide(true); msgContext.setProperty( Constants.Configuration.TRANSPORT_IN_URL, request.getRequestLine().getUri()); // http transport header names are case insensitive Map<String, String> headers = new TreeMap<String, String>( new Comparator<String>() { public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); for (Header header : request.getAllHeaders()) { String headerName = header.getName(); // if this header is already added if (headers.containsKey(headerName)) { /* this is a multi-value header */ // generate the key String key = NhttpConstants.EXCESS_TRANSPORT_HEADERS; // get the old value String oldValue = headers.get(headerName); // adds additional values to a list in a property of message context Map map; if (msgContext.getProperty(key) != null) { map = (Map) msgContext.getProperty(key); map.put(headerName, oldValue); } else { map = new MultiValueMap(); map.put(headerName, oldValue); // set as a property in message context msgContext.setProperty(key, map); } } headers.put(header.getName(), header.getValue()); } msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers); // find the remote party IP address and set it to the message context if (conn instanceof HttpInetConnection) { HttpInetConnection inetConn = (HttpInetConnection) conn; InetAddress remoteAddr = inetConn.getRemoteAddress(); if (remoteAddr != null) { msgContext.setProperty(MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress()); msgContext.setProperty(NhttpConstants.REMOTE_HOST, NhttpUtil.getHostName(remoteAddr)); remoteAddress = remoteAddr.getHostAddress(); } } msgContext.setProperty( RequestResponseTransport.TRANSPORT_CONTROL, new HttpCoreRequestResponseTransport(msgContext)); msgContext.setProperty( ServerHandler.SERVER_CONNECTION_DEBUG, conn.getContext().getAttribute(ServerHandler.SERVER_CONNECTION_DEBUG)); msgContext.setProperty(NhttpConstants.NHTTP_INPUT_STREAM, is); msgContext.setProperty(NhttpConstants.NHTTP_OUTPUT_STREAM, os); return msgContext; }