WebService客户端未使用HTTPS连接到Web Service Server

时间:2013-03-05 11:14:21

标签: java web-services https jboss jax-ws

我在JBoss AS7.1中部署了一个需要使用HTTPS的WebService。 我已经以这种方式在服务器上配置了standalone.xml:

  <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="8443"/>
        <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
            <ssl name="server-ssl" key-alias="server" password="secret" certificate-key-file="../standalone/configuration/server.keystore" protocol="TLSv1" verify-client="false"/>
        </connector>
        <virtual-server name="default-host" enable-welcome-root="true">
            <alias name="localhost"/>
            <alias name="example.com"/>
        </virtual-server>
    </subsystem>

<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>

密钥库位于正确的位置,我已添加到我的web.xml:

<security-constraint>
     <web-resource-collection>
         <web-resource-name>HTTPS Test</web-resource-name>
         <url-pattern>/*</url-pattern>
     </web-resource-collection>
     <user-data-constraint>
         <transport-guarantee>CONFIDENTIAL</transport-guarantee>
     </user-data-constraint>
</security-constraint>

WebService正在运行并使用HTTPS,实际上我可以通过从Web浏览器访问URL来验证它。

我的问题是客户端,它部署在另一台JBoss AS 7.1上,但不起作用。 我已经从wsdl创建了客户端,并修改了WebServicesService类的第一部分,以便使用https:

@WebServiceClient(name = "WebServicesService", 
wsdlLocation = "https://192.168.1.104:8443/Server/WebServices?wsdl",
targetNamespace = "http://webservices.foo.it/") 
@HandlerChain(file="to-server-handler-chain.xml")

public class WebServicesService extends Service {

public final static URL WSDL_LOCATION;

public final static QName SERVICE = new QName("http://webservices.foo.it/", "WebServicesService");
public final static QName WebServicesPort = new QName("http://webservices.foo.it/", "WebServicesPort");
static {
    URL url = null;
    try {
        url = new URL("https://192.168.1.104:8443/Server/WebServices?wsdl");
    } catch (MalformedURLException e) {
        java.util.logging.Logger.getLogger(WebServicesService.class.getName())
        .log(java.util.logging.Level.INFO, 
                "Can not initialize the default wsdl from {0}", "file");
    }
    WSDL_LOCATION = url;
}

public WebServicesService(URL wsdlLocation) {

    super(wsdlLocation, SERVICE);
}


public WebServicesService(URL wsdlLocation, QName serviceName) {
    super(wsdlLocation, serviceName);
}

public WebServicesService() {
    super(WSDL_LOCATION, SERVICE);
}

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public WebServicesService(WebServiceFeature ... features) {
    super(WSDL_LOCATION, SERVICE, features);
}

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public WebServicesService(URL wsdlLocation, WebServiceFeature ... features) {
    super(wsdlLocation, SERVICE, features);
}

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public WebServicesService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
    super(wsdlLocation, serviceName, features);
}

/**
 *
 * @return
 *     returns WebServices
 */
@WebEndpoint(name = "WebServicesPort")
public WebServices getWebServicesPort() {
    return super.getPort(WebServicesPort, WebServices.class);
}

/**
 * 
 * @param features
 *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
 * @return
 *     returns WebServices
 */
@WebEndpoint(name = "WebServicesPort")
public WebServices getWebServicesPort(WebServiceFeature... features) {
    return super.getPort(WebServicesPort, WebServices.class, features);
}

}

当我尝试建立第一个连接时,客户端JBoss打印:

[org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver] (http--192.168.1.102-8080-1) Cannot open stream for resource: https://192.168.1.104:8433/Server/WebServices?wsdl

然后例外:

[org.jboss.ws.common.invocation.InvocationHandlerJAXWS] (http--192.168.1.102-8080-1) Method invocation failed with exception: null: java.lang.reflect.InvocationTargetException
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https://192.168.1.104:8443/Server/WebServices?wsdl'.: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

使我的客户端无法使用HTTPS连接到服务器的问题是什么?

0 个答案:

没有答案