JBOSS EAP 6.4:无法在生成的WSDL中的“ soap:address”中使用HTTPS模式

问题描述

我已经修改了独立配置,以将HTTPS连接器与HTTP连接器一起使用:

 <subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="http" socket-binding="http"/>
    <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
        <ssl name="https" key-alias="test" password="testpwd" certificate-key-file="testjkspath"/>
    </connector>
    <virtual-server name="default-host" enable-welcome-root="false">
        <alias name="localhost"/>
        <rewrite name="redirect_https" pattern="^.*/service/(.*)" substitution="https://host.domain.com:8443/service/$1" flags="L,R=301">
            <condition name="condition-0" test="%{SERVER_PORT}" pattern="8080"/>
            <condition name="condition-1" test="%{HTTPS}" pattern="off"/>
        </rewrite>
    </virtual-server>
</subsystem>

使用此配置,我能够将HTTP流量传输到HTTPS URL。它工作正常。我也有一个用Java编写的Web服务:

@Stateless
@WebService(targetNamespace = "http://app.domain.com/usecase/serv1")
public class TestInterface {
    public ResultTO getResult(@WebParam(name = "getResultReq") final RequestRO getResultReq) {
        // some logic here
    }
}

一旦部署了应用程序(service.ear),我可以在以下位置看到wsdl:

https://host.domain.com:8443/service/wstest/TestInterface?wsdl

但是WSDL服务定义在“ soap:address”元素内使用HTTP URL:

<wsdl:service name="TestInterfaceService">
<wsdl:port binding="tns:TestInterfaceServiceSoapBinding" name="TestInterfacePort">
<soap:address location="http://host:8080/service/wstest/TestInterface"/>
</wsdl:port>
</wsdl:service>

可以从两个URL访问我的Web服务:

http://host:8080/service/wstest/TestInterface

https://host.domain.com:8443/service/wstest/TestInterface

如何更改生成的WSDL文件内“ soap:address”元素内生成的URL?

我尝试将独立XML中的Web服务模块配置更改为:

<subsystem xmlns="urn:jboss:domain:webservices:1.2">
    <modify-wsdl-address>true</modify-wsdl-address>
    <wsdl-host>host.domain.com</wsdl-host>
    <wsdl-secure-port>8443</wsdl-secure-port>
    <endpoint-config name="Standard-Endpoint-Config"/>
    <endpoint-config name="Recording-Endpoint-Config">
        <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
            <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
        </pre-handler-chain>
    </endpoint-config>
</subsystem>

此更改之后,WSDL将“ soap:address”显示为:

<wsdl:service name="TestInterfaceService">
<wsdl:port binding="tns:TestInterfaceServiceSoapBinding" name="TestInterfacePort">
<soap:address location="http://host.domain.com:8080/service/wstest/TestInterface"/>
</wsdl:port>
</wsdl:service>

端口未更改。 URI模式也未更改为HTTPS。我发现了几个SO线程(thread1thread2),它们要求在独立XML的web服务定义中添加“ wsdl-uri-scheme”属性。但是JBOSS EAP 6.4尚不支持

如果您对此有任何想法,请告诉我。如果您需要更多信息,请告诉我。

解决方法

我终于找到了如何使其与JBOSS EAP 6.4一起使用的方法。请参阅此RedHat knowledgebase

有多种方法。我按照选项1动态重写了soap:address。您需要做的就是使用wsdl-secure-port是webservice子系统,并将wsdl-host设置为“ jbossws.undefined.host”值:

<subsystem xmlns="urn:jboss:domain:webservices:1.2">
    <modify-wsdl-address>true</modify-wsdl-address>
    <wsdl-host>jbossws.undefined.host</wsdl-host>
    <wsdl-secure-port>8443</wsdl-secure-port>
    <endpoint-config name="Standard-Endpoint-Config"/>
    <endpoint-config name="Recording-Endpoint-Config">
        <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
            <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
        </pre-handler-chain>
    </endpoint-config>
</subsystem>

然后,WSDL用soap:address生成为:

https://host.domain.com:8443/service/wstest/TestInterface

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...