小编MrB*_*977的帖子

获取CXF端点的URL

情况

我正在使用Apache CXF 2.6.2将Web服务部署到Tomcat服务器.我正在使用CXFServlet和以下基于Spring的配置导出服务:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

    <jaxws:endpoint id="test_endpoint"
                    implementor="org.xyz.TestImpl"
                    address="/test"/>

    <bean id="testBean" class="org.xyz.TestBean">
        <property name="endpoint" ref="test_endpoint" />
    </bean>
</beans>
Run Code Online (Sandbox Code Playgroud)

在我的示例部署中,CXFServlet使用相对路径/服务,例如,由TestImpl类实现的Web服务可用作http://domain.com/tomcat-context/services/test.TestBean 类具有端点的设置器和它由Spring设定.

目标

我想确定使用端点字段在类TestBean中由端点test_endpoint提供的地址(URL).结果应该是"http://domain.com/tomcat-context/services/test".

我试过的

log.info("Endpoint set to " + endpoint);
log.info("Address: " + endpoint.getAddress());
org.apache.cxf.jaxws.EndpointImpl ep = (org.apache.cxf.jaxws.EndpointImpl) endpoint;
log.info("Other Address: " + ep.getBindingUri());
log.info("Props: " + ep.getProperties());
Run Code Online (Sandbox Code Playgroud)

但结果是公正的

Address: /Sachbearbeiter
Other Address: null
Props: {}
Run Code Online (Sandbox Code Playgroud)

如何获取完整的URL?有没有办法没有自己建造它?

java web-services cxf

6
推荐指数
1
解决办法
8328
查看次数

标签 统计

cxf ×1

java ×1

web-services ×1