Проблема Гендлера CXF SOAP - PullRequest
0 голосов
/ 26 декабря 2018

У меня проблема с запуском HTTPS SERVER для публикации службы CXF SOAP, я сделал тот же POC на JAX-WS и получил правильный SOAP-ответ, но столкнулся с проблемой при публикации через CXF, я создаю HTTPS-сервер и публикую SOAP с помощью

        CorrelationIdFeature correlationIdFeature = new CorrelationIdFeature();

    HttpsServer httpsServer = null;

    HttpHandler httpHandler = new RequestHandler();
    try
    {
        httpsServer = this.createHttpsServer(config);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }


    if (StringUtils.isNotEmpty(processingServiceUrl))
    {
        HttpContext httpContext = httpsServer.createContext(processingServiceUrl);

        EndpointImpl transactionProcessingEndpoint = (EndpointImpl) Endpoint.create(HTTPBinding.HTTP_BINDING, transactionProcessingService, correlationIdFeature);

        transactionProcessingEndpoint.publish(httpContext);
        httpsServer.start();

Но при отправке SOAP-запроса появляется ошибка "

500 Внутренняя ошибка сервера

Нет обработчика для контекста"

Я изменяю запрос, добавляя HTTPHandler

        HttpContext httpContext = httpsServer.createContext(processingServiceUrl, httpHandler);

и вот реализация HTTPHandler

public class RequestHandler implements HttpHandler {

@Override
public void handle(HttpExchange he) throws IOException {  

    he.close();
}

Что мне делать внутри метода handle (HttpExchange), чтобы делегировать мой запрос веб-службе Endpoint SOAP для вызова правильного метода, как в запросе.любезно предложите

вот мой код создания сервера

    private HttpsServer createHttpsServer(TXEConfig config) throws NumberFormatException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, UnrecoverableKeyException, KeyManagementException
{
    ExtendedProperties moduleProperties = config.getModuleProperties();
    String port = moduleProperties.getProperty("sslPort", "8777");
    String keyStorePath = moduleProperties.getProperty("keyStorePath", "keystore.pkcs12");
    String keyStorePassword = moduleProperties.getProperty("keyStorePassword", "*****");

    KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    KeyStore keyStore = KeyStore.getInstance("pkcs12");
    keyStore.load(new FileInputStream(keyStorePath), keyStorePassword.toCharArray());
    keyFactory.init(keyStore, keyStorePassword.toCharArray());

    TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    trustFactory.init(keyStore);

    SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
    sslContext.init(keyFactory.getKeyManagers(), trustFactory.getTrustManagers(), new SecureRandom());

    final SSLEngine sslEngine = sslContext.createSSLEngine();
    sslEngine.setEnabledProtocols(new String[]{"TLSv1.2"});

    HttpsConfigurator configurator = new HttpsConfigurator(sslContext)
    {
        public void configure(HttpsParameters parms)
        {
            parms.setCipherSuites(sslEngine.getEnabledCipherSuites());
            parms.setProtocols(sslEngine.getEnabledProtocols());
        }
    };

    InetSocketAddress addr = new InetSocketAddress(Integer.parseInt(port));

    BusFactory.getDefaultBus();

    HttpsServer httpsServer = HttpsServer.create(addr, 10);
    httpsServer.setHttpsConfigurator(configurator);
    httpsServer.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100)));

    return httpsServer;
}
...