CXF SOAP的处理程序问题

时间:2018-12-26 12:56:01

标签: web-services soap https cxf soapserver

我面临启动HTTPS SERVER来发布CXF SOAP服务的问题,我在JAX-WS上执行了相同的POC并获得了正确的SOAP响应,但是在通过CXF进行发布时却遇到了问题,我正在创建HTTPS服务器并通过

        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 Web服务以像请求中那样调用适当的方法。 请建议

这是我的服务器创建代码

    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;
}

0 个答案:

没有答案