java - 更改 schemaLocation 和 soap :address location in runtime generated WSDL with JAX-WS

标签 java web-services wsdl jax-ws

是否可以在 JAX-WS WSDL 中配置位置(schemaLocationsoap:address location)?
当我部署下面的示例时,“servername”将是 localhost,“serverport”将是 Web 应用程序的本地端口号。

但是,我想将它们重新配置为重定向到服务的代理服务器名称和服务器端口。这可能吗?我将如何实现?

部署环境为Tomcat和Apache。

我有以下服务类:

@WebService
public class AuthenticationService {
....
public AuthenticationService(){}

@WebMethod
    public AuthenticationResult checkAuthentication(
        @WebParam(name = "authentication") Authentication authentication,
        @WebParam(name = "privilege") Privilege privilege) {
    ....
}
}

运行时,WSDL 如下所示:

<definitions targetNamespace="http://authentication.service.ws.ijs/" name="AuthenticationServiceService">
<types>

    <xsd:schema>
        <xsd:import namespace="http://authentication.service.ws.ijs/" schemaLocation="http://servername:serverport/WebAppName/AuthenticationService?xsd=1"/>
    </xsd:schema>
</types>

<message name="checkAuthentication">
    <part name="parameters" element="tns:checkAuthentication"/>
</message>

<message name="checkAuthenticationResponse">
    <part name="parameters" element="tns:checkAuthenticationResponse"/>
</message>

<portType name="AuthenticationService">

    <operation name="checkAuthentication">
        <input wsam:Action="http://authentication.service.ws.ijs/AuthenticationService/checkAuthenticationRequest" message="tns:checkAuthentication"/>
        <output wsam:Action="http://authentication.service.ws.ijs/AuthenticationService/checkAuthenticationResponse" message="tns:checkAuthenticationResponse"/>
    </operation>

</portType>

<binding name="AuthenticationServicePortBinding" type="tns:AuthenticationService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

    <operation name="checkAuthentication">
        <soap:operation soapAction=""/>

        <input>
            <soap:body use="literal"/>
        </input>

        <output>
            <soap:body use="literal"/>
        </output>
    </operation>

</binding>

<service name="AuthenticationServiceService">

    <port name="AuthenticationServicePort" binding="tns:AuthenticationServicePortBinding">
        <soap:address location="http://servername:serverport/WebAppName/AuthenticationService"/>
    </port>
</service>
</definitions>

如有任何帮助,我们将不胜感激。

最佳答案

如果您在请求中保留原始主机名(例如,如果您使用mod_proxy,请使用ProxyPreserveHost On)这应该会修复您的网址,如果你使用相同的协议(protocol)。如果您的代理在 httpshttp 之间切换,您可能仍然会遇到问题。

关于java - 更改 schemaLocation 和 soap :address location in runtime generated WSDL with JAX-WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8004067/

相关文章:

java - WSDL 使用 SOAP 1.2 时生成 webservice 客户端

javascript - Node-soap 客户端-服务器测试

java - 为什么 "array instanceof Iterable"不能用 Java 编译?

java - 是否存在允许跨平台错误记录和跟踪多个应用程序的工具?

java - EventQueue.isDispatchThread() 中的无限循环

JavaEE : Web Service Deployed Successfully but Tester is not Working

web-services - Web 服务测试隔离 - 但何时验证 Web 服务本身?

java - 是否可以使用 .Net Framework/Java 创建 SQLite DB 并使用 Web 服务将 DB 推送到 iPhone?

wsdl - azure 生成错误的 wsdl 地址

java - 在 Hibernate 中使用多个列表