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?

Aleksander Gralak
  • 1,509
  • 10
  • 26
  • How come you need different soapActions for your test and production service? If both services use the same WSDL, you can define the soapAction once and use the same soap action for test and prod. – Yogesh Chawla Feb 07 '13 at 21:09
  • @YogeshChawla If I am not wrong due to documentation the attribute `soapAcion` needs to use absolute url. Therefore I can not put thererelative one `dsSOAP/operation1`. Having the same value for both test and production I might end up with clients start invoking production server instead of the test server. – Aleksander Gralak Feb 08 '13 at 10:34
  • 1
    Hi Aleksander, It should be a complete not relative URI but does not need to describe the actual physical address being called. You can use: "http://example.org/dsSOAP/operation1" for both platforms. Otherwise you would need unique WSDLs per platform. – Yogesh Chawla Feb 08 '13 at 15:49
  • I do not want to have different WSDL for each environment. That is why I was looking for a way to make `soapAction` variable. I know that this attribute is not the endpoint location, nevertheless I feel uncomfortable having prodcution URI in test environment. For me it makes no difference. However `soapAction` is being used for routing as far as I know. Therefore for someone else it might be important. – Aleksander Gralak Feb 11 '13 at 08:29
  • For routing your messages, I would take a look at WS-Addressing: http://www.w3.org/Submission/ws-addressing/ However you might be dealing with an existing implementation that uses SoapAction for routing. – Yogesh Chawla Feb 11 '13 at 16:02

1 Answers1

1

You dont need to specify an absolute URL, you dont need either to specify a URL. "operation1" would be enough. See some official examples at http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528

Linking the soap action with the environment the instance is running is not a "best practice".

jmhostalet
  • 4,399
  • 4
  • 38
  • 47