Sha256: 638df08d3e0ecf05397c66148296b8b85a7a57fabc852dedb1a0f08845256f1a

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

# encoding: ASCII-8BIT
require 'soap/rpc/driver'
require 'soap/header/simplehandler'


class DefaultNSFilter < SOAP::Filter::Handler
  def on_outbound(envelope, opt)
    opt[:default_ns] = @default_ns
    envelope
  end

  def initialize
    @default_ns = SOAP::NS.new
    @default_ns.assign('urn:custom_ns', 'myns')
  end
end


class MyHeaderHandler < SOAP::Header::SimpleHandler
  MyHeaderName = XSD::QName.new('urn:custom_ns', 'myheader')

  def initialize
    super(MyHeaderName)
  end

  def on_simple_outbound
    { "hello" => "world" }
  end
end


client = SOAP::RPC::Driver.new("http://localhost:7171", "urn:custom_ns")
client.add_method('echo', 'amt')
client.filterchain << DefaultNSFilter.new
client.headerhandler << MyHeaderHandler.new
client.wiredump_dev = STDOUT

p client.echo(1)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soap5r-2.0.3 sample/howto/custom_ns/client.rb
soap5r-2.0.2 sample/howto/custom_ns/client.rb
soap5r-2.0.1 sample/howto/custom_ns/client.rb
soap5r-2.0.0 sample/howto/custom_ns/client.rb
soap5r-2.0.0.20120130130121 sample/howto/custom_ns/client.rb