5

I am developing webservice using CXF. I use HTTP binding so according to http://www.w3.org/TR/wsdl#_soap:operation soapaction is mandatory for this type of transport.

The problem is that I want to deploy the same application for test and production server. I would like to do it without rebuilding application or keeping external WSDL files, which will add one more thing on maintenance list.

I had the same problem with location, but that one was trivial to solve. I used publishedEndpointUrl in endpoint configuration to set proper value. The value is retrieved during initialization of application from external property file, which I placed on classpath tomcat/common/classes .

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
  <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>classpath:ws.properties</value>
      </list>
    </property>
  </bean>
  <jaxws:endpoint xmlns:tns="http://example.org/ds" id="ds" implementor="org.example.Ds" wsdlLocation="wsdl/ds.wsdl" endpointName="tns:dsSOAP" serviceName="tns:Ds" address="/dsSOAP" publishedEndpointUrl="${publishedEndpointUrl}">
    <jaxws:features>
      <bean class="org.apache.cxf.feature.LoggingFeature" />
    </jaxws:features>
  </jaxws:endpoint>
</beans>

I would like to achieve the same functionality for soapaction. The value for this attribute should be not relative URI. So for test it should be:

<soap:operation soapAction="https://test.example.org/dsSOAP/operation1" />

and for production

<soap:operation soapAction="https://example.org/dsSOAP/operation1" />

any idea how to achieve this?

4

1 回答 1

1

您不需要指定绝对 URL,也不需要指定 URL。“操作1”就足够了。请参阅http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528上的一些官方示例

将soap 动作与实例运行的环境联系起来并不是“最佳实践”。

于 2013-10-08T14:36:11.443 回答