Results 1 to 6 of 6

Thread: Select Web Service operation

  1. #1
    Join Date
    Jul 2008
    Posts
    21

    Default Select Web Service operation

    Using Web Service Outbound Gateway, how do I select which operation (i.e. SOAP Action) I want to call?
    Code:
    <ws:outbound-gateway id="simpleGateway"
                         request-channel="inputChannel"
                         uri="http://example.org"/>
    Is it possible to bind each operation in a Gateway Interface to the a given Web Service Operation? Using annotations?

    Thanx for your help

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Before sending the outbound Message, you can add a header with the name defined in the constant: WebServiceHeaders.SOAP_ACTION

    The value of that header will then be set as the SoapAction header in the created SOAP Message.

    The WebServices sample includes this with a generic header-enricher (hence, the actual name is used instead of the constant):
    Code:
    <chain input-channel="fahrenheitChannel" output-channel="celsiusChannel">
        <header-enricher>
            <header name="springintegration_ws_soapAction" value="http://tempuri.org/FahrenheitToCelsius"/>
        </header-enricher>
        <ws:outbound-gateway uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
    </chain>

  3. #3
    Join Date
    Jul 2008
    Posts
    21

    Default

    Is it possible to do something like:
    Code:
    public interface TempConvertGateway {
    
         @Gateway(requestChannel="fahrenheitChannel", replyChannel="celsiusChannel")
         @Header(name="soapAction",value="http://tempuri.org/FahrenheitToCelsius")
         int convertFahrenheitToCelsius(int temp);
    }

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Actually, you should be able to do something like this:
    Code:
    public interface TempConvertGateway {
    
         @Gateway(requestChannel="fahrenheitChannel", replyChannel="celsiusChannel")
         int convertFahrenheitToCelsius(int temp, @Header(WebServiceHeaders.SOAP_ACTION) String soapAction);
    }
    That means you need to pass the soap action value when calling the gateway, but hard-coding such a value in an annotation is probably not a good idea.

  5. #5
    Join Date
    Jul 2008
    Posts
    21

    Default

    Quote Originally Posted by Mark Fisher View Post
    That means you need to pass the soap action value when calling the gateway, but hard-coding such a value in an annotation is probably not a good idea.
    I don't think the SOAP Action will change, so I don't mind putting in the code. It's what I am going to do, place it in the caller code.

    I thank you for your help.

  6. #6
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    No problem. I hope that works well for you. Hardcoding in the caller is probably better than hardcoding in the annotation. At least it could be refactored in the future to use Dependency Injection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •