HTTPI executes HTTP GET using the net_http adapter             | ETA:
--:--:--
SOAP request: http://ec.europa.eu/taxation_customs/vies/services/checkVatService
SOAPAction: "checkVat", Content-Type: text/xml;charset=UTF-8, Content-
Length: 476
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://
www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ins0="urn:ec.europa.eu:taxud:vies:services:checkVat:types"><env:Body><ins0:checkVat><ins0:countryCode>DE</
ins0:countryCode><ins0:vatNumber>271788816</ins0:vatNumber></
ins0:checkVat></env:Body></env:Envelope>
HTTPI executes HTTP POST using the net_http adapter
SOAP response (status 200):
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/"><soapenv:Body><urn:checkVatResponse
xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types"><urn:countryCode>DE</
urn:countryCode><urn:vatNumber>271788816</
urn:vatNumber><urn:requestDate>2011-11-23+01:00</
urn:requestDate><urn:valid>true</urn:valid></urn:checkVatResponse></
soapenv:Body></soapenv:Envelope>
#<Savon::SOAP::Response:0x69156aa8>
I am trying to have Fakeweb simulate the response somehow (HTTP POST).
I can see in the GET there is a SOAP request:
http://ec.europa.eu/taxation_customs/vies/services/checkVatService
but in the POST there is no uri.
    def uri
      "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"
    end
    def register_fault type
      FakeWeb.register_uri :post, uri, :body => fault(type), :status
=> '500'
    end
  def execute!
    set_vat_nr
    set_country_code
    @response = client.request :urn, :checkVat, body: {countryCode:
country_code, vatNumber: vat_nr }
    puts response
  end
  module Faker
    def success value
      success_envelope do
        %Q{
        <urn:checkVatResponse
xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
          <urn:countryCode>BG</urn:countryCode>
          <urn:vatNumber>12345677</urn:vatNumber>
          <urn:requestDate>2011-11-23+01:00</urn:requestDate>
          <urn:valid>#{value}</urn:valid>
        </urn:checkVatResponse>
        }
      end
    end
    def success_envelope &block
      %Q{
        <?xml version='1.0' encoding='UTF-8'?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/
soap/envelope/">
           <soapenv:Body>
              #{yield}
           </soapenv:Body>
        </soapenv:Envelope>
      }
    end
end
For some reason I get an ArgumentError: Invalid URL and not the
ServiceUnavailable I am trying to simulate.
  describe 'simulate unavailable' do
    before do
      EuVatNumberCheck.register_fault 'MS_UNAVAILABLE'
    end
    specify do
      lambda { EuVatNumberCheck.new('DE+271788816').execute! }.should
raise_error(SOAPService::ServiceUnavailable)
    end
  end
Am I doing something wrong with respect to POST or GET and the Fakeweb
config?
Thanks!