Sha256: ccd9aa1a5e931dc04e8e5a80fd28694dfedac004c8b5bf9366858627a3fa8768

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

# encoding: ASCII-8BIT
require 'soap/rpc/standaloneServer'
require 'soap/filter'


class FilterTestServer < SOAP::RPC::StandaloneServer
  class Servant
    def self.create
      new
    end

    def echo(amt)
      amt
    end
  end

  class ServerFilter1 < SOAP::Filter::Handler
    # 15 -> 30
    def on_outbound(envelope, opt)
      unless envelope.body.is_fault
        node = envelope.body.root_node
        node.retval = SOAP::SOAPInt.new(node.retval.data * 2)
        node.elename = XSD::QName.new(nil, 'return')
      end
      envelope
    end

    # 4 -> 5
    def on_inbound(xml, opt)
      xml = xml.sub(/4/, '5')
      xml
    end
  end

  class ServerFilter2 < SOAP::Filter::Handler
    # 5 -> 15
    def on_outbound(envelope, opt)
      unless envelope.body.is_fault
        node = envelope.body.root_node
        node.retval = SOAP::SOAPInt.new(node.retval.data + 10)
        node.elename = XSD::QName.new(nil, 'return')
      end
      envelope
    end

    # 5 -> 6
    def on_inbound(xml, opt)
      xml = xml.sub(/5/, '6')
      xml
    end
  end

  def initialize(*arg)
    super
    add_rpc_servant(Servant.new, "urn:filter")
    self.filterchain << ServerFilter1.new
    self.filterchain << ServerFilter2.new
  end
end


if __FILE__ == $0
  server = FilterTestServer.new(self.class.name, nil, '0.0.0.0', 7171)
  trap("INT") do
    server.shutdown
  end
  server.start
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soap5r-2.0.3 sample/howto/filter/server.rb
soap5r-2.0.2 sample/howto/filter/server.rb
soap5r-2.0.1 sample/howto/filter/server.rb
soap5r-2.0.0 sample/howto/filter/server.rb
soap5r-2.0.0.20120130130121 sample/howto/filter/server.rb