Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not get it to work (using JRuby 1.7.10 and Savon 2.3.0) #549

Closed
fjyaniez opened this issue Feb 11, 2014 · 17 comments
Closed

Can not get it to work (using JRuby 1.7.10 and Savon 2.3.0) #549

fjyaniez opened this issue Feb 11, 2014 · 17 comments

Comments

@fjyaniez
Copy link

I'm triying to use Savon to check if an european VAT is valid without success:

jruby-1.7.10 :001 > client = Savon.client(wsdl: "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
=> #<Savon::Client:0x621ee2de @globals=#<Savon::GlobalOptions:0x59c08f25 @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x23716cfd @logdev=#<Logger::LogDevice:0x6baa6838 @shift_age=nil, @filename=nil, @dev=#<IO:fd 1>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0xa06bc1 @mon_count=0, @mon_mutex=#<Mutex:0x24024c39>, @mon_owner=nil>, @shift_size=nil>, @formatter=#<Logger::SimpleFormatter:0x12da44a7 @datetime_format=nil>, @progname=nil, @default_formatter=#<Logger::Formatter:0x37d1399c @datetime_format=nil>, @level=0>, :log=>true, :filters=>[], :pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:0x91d4d65@/Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/savon-2.3.3/lib/savon/options.rb:56 (lambda)>, :multipart=>false, :wsdl=>"http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"}>, @wsdl=#<Wasabi::Document:0x62c4268f @document="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", @request=#<HTTPI::Request:0x3bbfa8f1>>>
jruby-1.7.10 :002 > client.operations
HTTPI GET request to ec.europa.eu (net_http)
NoMethodError: undefined method `element_children' for nil:NilClass
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:299:in `sections'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:292:in `section'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:282:in `schemas'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:67:in `parse_namespaces'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:54:in `parse'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:160:in `parse'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:146:in `parser'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:63:in `soap_actions'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/savon-2.3.3/lib/savon/client.rb:28:in `operations'
    from (irb):2:in `evaluate'
    from org/jruby/RubyKernel.java:1119:in `eval'
    from org/jruby/RubyKernel.java:1519:in `loop'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands/console.rb:47:in `start'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands/console.rb:8:in `start'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands.rb:41:in `(root)'
    from org/jruby/RubyKernel.java:1083:in `require'
    from script/rails:6:in `(root)'jruby-1.7.10 :003 >

Does it work for any of you?

Thanks.

@tjarratt
Copy link
Contributor

@fjyaniez I just installed jruby-1.7.9 and this seems to work fine:

jruby-1.7.9 :003 > client = Savon.client(wsdl: "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
 => #<Savon::Client:0xa82570e @wsdl=#<Wasabi::Document:0x73215d85 @document="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", @request=#<HTTPI::Request:0x138301d0>>, @globals=#<Savon::GlobalOptions:0x7dec08b1 @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x1d0a3e63 @logdev=#<Logger::LogDevice:0xb85e47a @filename=nil, @shift_age=nil, @dev=#<IO:fd 1>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x35b0b7f @mon_count=0, @mon_mutex=#<Mutex:0x4e4fc091>, @mon_owner=nil>, @shift_size=nil>, @formatter=nil, @progname=nil, @default_formatter=#<Logger::Formatter:0x55eb97c1 @datetime_format=nil>, @level=0>, :log=>true, :filters=>[], :pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:0x5e382bf8@/Users/tjarratt/git/savon/lib/savon/options.rb:56 (lambda)>, :multipart=>false, :wsdl=>"http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"}>> 
jruby-1.7.9 :004 > client.operations
D, [2014-02-13T13:14:29.239000 #9951] DEBUG -- : HTTPI GET request to ec.europa.eu (httpclient)
 => [:check_vat, :check_vat_approx]

It looks like I'm using Wasabi v3.2.2 locally, so maybe I'll bump that and upgrade to jruby 1.7.10 and see how it works.

@fjyaniez
Copy link
Author

Hi @tjarratt

I'm also using Wasabi 3.2.2. If you could try using jruby 1.7.10 it would be great :) Thanks!

@tjarratt
Copy link
Contributor

@fjyaniez I'm sad to report that I was able to use Savon v2.3.3 on jruby 1.7.10 with Wasabi v3.2.3 without any issue.

Would you mind attaching a gist of the WSDL your client is getting? I would probably use an http client like httparty to fetch the document before your client tries to call #operations

eg:

require 'httparty'
puts "WSDL is #{HTTParty.Get('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')}.inspect"
client = Savon.client(wsdl: "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
puts client.operations.inspect

Relevant output from my irb session:

± bundle exec irb
jruby-1.7.10 :001 > RUBY_VERSION
 => "1.9.3" 
jruby-1.7.10 :002 > require 'savon'
 => true 
jruby-1.7.10 :003 > client = Savon.client(wsdl: "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
 => #<Savon::Client:0x4aac53a8 @wsdl=#<Wasabi::Document:0x77a860e4 @document="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", @request=#<HTTPI::Request:0x4f71561b>>, @globals=#<Savon::GlobalOptions:0x19cc2f5c @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x1de54f07 @logdev=#<Logger::LogDevice:0x39a763e6 @filename=nil, @shift_age=nil, @dev=#<IO:fd 1>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x1c8fae9c @mon_count=0, @mon_mutex=#<Mutex:0x1d10926a>, @mon_owner=nil>, @shift_size=nil>, @formatter=nil, @progname=nil, @default_formatter=#<Logger::Formatter:0x2afc7c0e @datetime_format=nil>, @level=0>, :log=>true, :filters=>[], :pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:0x2634912e@/Users/tjarratt/git/savon/lib/savon/options.rb:56 (lambda)>, :multipart=>false, :wsdl=>"http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"}>> 
jruby-1.7.10 :004 > client.operations
D, [2014-02-13T19:31:38.817000 #13774] DEBUG -- : HTTPI GET request to ec.europa.eu (httpclient)
 => [:check_vat, :check_vat_approx] 
jruby-1.7.10 :005 > Savon::VERSION
 => "2.3.3" 
jruby-1.7.10 :006 > Wasabi::VERSION
 => "3.2.3" 
jruby-1.7.10 :007 > 

@fjyaniez
Copy link
Author

Hi,

I found a difference in my setup, I'm using ruby 2.0.0 compatibility:

ruby '2.0.0', engine: 'jruby', engine_version: '1.7.10'
jruby-1.7.10 :007 > puts "WSDL is #{HTTParty.get('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')}.inspect"
WSDL is <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:tns1="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:impl="urn:ec.europa.eu:taxud:vies:services:checkVat" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
  <xsd:documentation>
     Specific disclaimer for this service ----------------------------------------- The
        objective of this Internet site is to allow persons involved in the intra-Community supply of
        goods or of services to obtain confirmation of the validity of the VAT identification number of
        any specified person, in accordance to article 27 of Council Regulation (EC) No. 1798/2003 of 7
        October 2003. Any other use and any extraction and use of the data which is not in conformity
        with the objective of this site is strictly forbidden. Any retransmission of the contents of
        this site, whether for a commercial purpose or otherwise, as well as any more general use other
        than as far as is necessary to support the activity of a legitimate user (for example: to draw
        up their own invoices) is expressly forbidden. In addition, any copying or reproduction of the
        contents of this site is strictly forbidden. The European Commission maintains this website to
        enhance the access by taxable persons making intra-Community supplies to verification of their
        customers VAT identification numbers. Our goal is to supply instantaneous and accurate
        information. However the Commission accepts no responsibility or liability whatsoever with
        regard to the information obtained using this site. This information: - is obtained from Member
        States databases over which the Commission services have no control and for which the Commission
        assumes no responsibility; it is the responsibility of the Member States to keep their databases
        complete, accurate and up to date; - is not professional or legal advice (if you need specific
        advice, you should always consult a suitably qualified professional); - does not in itself give
        a right to exempt intra-Community supplies from Value Added Tax; - does not change any
        obligations imposed on taxable persons in relation to intra-Community supplies. It is our goal
        to minimise disruption caused by technical errors. However some data or information on our site
        may have been created or structured in files or formats which are not error-free and we cannot
        guarantee that our service will not be interrupted or otherwise affected by such problems. The
        Commission accepts no responsibility with regard to such problems incurred as a result of using
        this site or any linked external sites. This disclaimer is not intended to limit the liability
        of the Commission in contravention of any requirements laid down in applicable national law nor
        to exclude its liability for matters which may not be excluded under that law. Usage: The
        countryCode input parameter must follow the pattern [A-Z]{2} The vatNumber input parameter must
        follow the [0-9A-Za-z\+\*\.]{2,12} In case of problem, the returned FaultString can take the
        following specific values: - INVALID_INPUT: The provided CountryCode is invalid or the VAT
        number is empty; - SERVICE_UNAVAILABLE: The SOAP service is unavailable, try again later; -
        MS_UNAVAILABLE: The Member State service is unavailable, try again later or with another Member
        State; - TIMEOUT: The Member State service could not be reach in time, try again later or with
        another Member State; - SERVER_BUSY: The service can't process your request. Try again latter.
    </xsd:documentation>

  <wsdl:types>
    <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
            <xsd:element name="checkVat">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="countryCode" type="xsd:string"/>
                        <xsd:element name="vatNumber" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="checkVatResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="countryCode" type="xsd:string"/>
                        <xsd:element name="vatNumber" type="xsd:string"/>
                        <xsd:element name="requestDate" type="xsd:date"/>
                        <xsd:element name="valid" type="xsd:boolean"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="name" nillable="true" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="address" nillable="true" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="checkVatApprox">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="countryCode" type="xsd:string"/>
                        <xsd:element name="vatNumber" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderName" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyType" type="tns1:companyTypeCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderStreet" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderPostcode" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCity" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="requesterCountryCode" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="requesterVatNumber" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="checkVatApproxResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="countryCode" type="xsd:string"/>
                        <xsd:element name="vatNumber" type="xsd:string"/>
                        <xsd:element name="requestDate" type="xsd:date"/>
                        <xsd:element name="valid" type="xsd:boolean"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderName" nillable="true" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyType" nillable="true" type="tns1:companyTypeCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderAddress" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderStreet" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderPostcode" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCity" type="xsd:string"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderNameMatch" type="tns1:matchCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCompanyTypeMatch" type="tns1:matchCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderStreetMatch" type="tns1:matchCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderPostcodeMatch" type="tns1:matchCode"/>
                        <xsd:element maxOccurs="1" minOccurs="0" name="traderCityMatch" type="tns1:matchCode"/>
                        <xsd:element name="requestIdentifier" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:simpleType name="companyTypeCode">
                <xsd:restriction base="xsd:string">
                    <xsd:pattern value="[A-Z]{2}\-[1-9][0-9]?"/>
                </xsd:restriction>
            </xsd:simpleType>
            <xsd:simpleType name="matchCode">
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="1">
                        <xsd:annotation>
                            <xsd:documentation>VALID</xsd:documentation>
                        </xsd:annotation>
                    </xsd:enumeration>
                    <xsd:enumeration value="2">
                        <xsd:annotation>
                            <xsd:documentation>INVALID</xsd:documentation>
                        </xsd:annotation>
                    </xsd:enumeration>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:schema>
  </wsdl:types>
  <wsdl:message name="checkVatRequest">
    <wsdl:part name="parameters" element="tns1:checkVat">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="checkVatApproxResponse">
    <wsdl:part name="parameters" element="tns1:checkVatApproxResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="checkVatApproxRequest">
    <wsdl:part name="parameters" element="tns1:checkVatApprox">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="checkVatResponse">
    <wsdl:part name="parameters" element="tns1:checkVatResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="checkVatPortType">
    <wsdl:operation name="checkVat">
      <wsdl:input name="checkVatRequest" message="impl:checkVatRequest">
    </wsdl:input>
      <wsdl:output name="checkVatResponse" message="impl:checkVatResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="checkVatApprox">
      <wsdl:input name="checkVatApproxRequest" message="impl:checkVatApproxRequest">
    </wsdl:input>
      <wsdl:output name="checkVatApproxResponse" message="impl:checkVatApproxResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="checkVatBinding" type="impl:checkVatPortType">
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="checkVat">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="checkVatRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="checkVatResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="checkVatApprox">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="checkVatApproxRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="checkVatApproxResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="checkVatService">
    <wsdl:port name="checkVatPort" binding="impl:checkVatBinding">
      <wsdlsoap:address location="http://ec.europa.eu/taxation_customs/vies/services/checkVatService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
.inspect
 => nil
jruby-1.7.10 :008 > client = Savon.client(wsdl: "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
 => #<Savon::Client:0x61019643 @globals=#<Savon::GlobalOptions:0x2f303a76 @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x27b9b888 @logdev=#<Logger::LogDevice:0x1201fd18 @shift_age=nil, @filename=nil, @dev=#<IO:fd 1>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x408f3be4 @mon_count=0, @mon_mutex=#<Mutex:0x7ba516d8>, @mon_owner=nil>, @shift_size=nil>, @formatter=#<Logger::SimpleFormatter:0x137efe53 @datetime_format=nil>, @progname=nil, @default_formatter=#<Logger::Formatter:0x766b0524 @datetime_format=nil>, @level=0>, :log=>true, :filters=>[], :pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:0x6c1ebb38@/Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/savon-2.3.3/lib/savon/options.rb:56 (lambda)>, :multipart=>false, :wsdl=>"http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"}>, @wsdl=#<Wasabi::Document:0x559590fc @document="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", @request=#<HTTPI::Request:0x4e61bc49>>>
jruby-1.7.10 :009 > puts client.operations.inspect
HTTPI GET request to ec.europa.eu (net_http)
NoMethodError: undefined method `element_children' for nil:NilClass
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:299:in `sections'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:292:in `section'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:282:in `schemas'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:67:in `parse_namespaces'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/parser.rb:54:in `parse'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:160:in `parse'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:146:in `parser'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/wasabi-3.2.3/lib/wasabi/document.rb:63:in `soap_actions'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/savon-2.3.3/lib/savon/client.rb:28:in `operations'
    from (irb):9:in `evaluate'
    from org/jruby/RubyKernel.java:1119:in `eval'
    from org/jruby/RubyKernel.java:1519:in `loop'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from org/jruby/RubyKernel.java:1282:in `catch'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands/console.rb:47:in `start'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands/console.rb:8:in `start'
    from /Users/fjyaniez/.rvm/gems/jruby-1.7.10@port-monitor/gems/railties-3.2.16/lib/rails/commands.rb:41:in `(root)'
    from org/jruby/RubyKernel.java:1083:in `require'
    from script/rails:6:in `(root)'jruby-1.7.10 :010 > Savon::VERSION
 => "2.3.3"
jruby-1.7.10 :011 > Wasabi::VERSION
 => "3.2.3"
jruby-1.7.10 :012 > RUBY_VERSION
 => "2.0.0"

I'm going to check with 1.9.3 and let you know... thanks!

@fjyaniez
Copy link
Author

And I can confirm the problem is using JRuby in ruby 2.0.0 mode.

@tjarratt
Copy link
Contributor

Oh, great, thanks for providing that debug information @fjyaniez! It looks like the bug is in Wasabi under Jruby 2.0.0 mode then. I'll keep this open until savonrb/wasabi#42 is fixed.

@fjyaniez
Copy link
Author

Thank you so much @tjarratt

@tjarratt
Copy link
Contributor

tjarratt commented Mar 6, 2014

Good news -- I've finally found a reproducible testcase for this issue. I've heard grumbles about this bug from a few other people, so I'm hoping to find a resolution this week.

@tjarratt
Copy link
Contributor

tjarratt commented Mar 6, 2014

Curious -- on my machine it looks like it's failing because the XML passed to nokogiri is an empty string. It seems to work if you fetch the wsdl separately and then pass it to savon. Does that match what you're seeing, @fjyaniez?

require 'savon'

wsdl = File.read("path/to/checkVatService.wsdl")
client = Savon.client(wsdl: wsdl)
client.operations # [:check_vat, :check_vat_approx] SUCCESS

@tjarratt
Copy link
Contributor

tjarratt commented Mar 7, 2014

Narrowed this down a bit further to the httpi gem. Apparently making a GET request with jruby 1.7.10 to this URL returns an empty response body. Looping in @rogerleite -- maybe he has some insight into why this is happening?

Shell

export JRUBY_OPTS=--2.0

Gemfile

source 'https://rubygems.org'

ruby '2.0.0', engine: 'jruby', engine_version: '1.7.10'
gem 'savon', '~> 2.3.2'

test.rb

require 'httpi'
HTTPI.get("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")

Making a request with HTTParty, curl or Net::HTTP works, however.

@rogerleite
Copy link
Member

Using JRuby the response body is empty.
I didn't find the problem, for now, the only weird thing that i found was response headers:

MRI 1.9.3
[4] pry(main)> response.headers
=> {"Date"=>"Fri, 07 Mar 2014 12:08:15 GMT",
 "Accept-Ranges"=>"none",
 "Content-Length"=>"10201",
 "Last-Modified"=>"Fri, 28 Jun 2013 20:27:21 GMT",
 "Server"=>"Europa",
 "Proxy-Connection"=>"Keep-Alive",
 "Connection"=>"Keep-Alive"}

JRuby 1.7.10
[1] pry(main)> response
=> #<HTTPI::Response:0x42d0a46b
 @code=200,
 @headers=
  {"date"=>"Fri, 07 Mar 2014 12:09:26 GMT",
   "accept-ranges"=>"none",
   "last-modified"=>"Fri, 28 Jun 2013 20:27:21 GMT",
   "server"=>"Europa",
   "transfer-encoding"=>"chunked",
   "proxy-connection"=>"Keep-Alive",
   "connection"=>"Keep-Alive"},

I think the problem is related to Transfer-Encoding "chunked". If this works on HTTParty, the next step is to discover what magic it does. I'll try to look at this on afternoon.

@rogerleite
Copy link
Member

Ok. I quit. I can't find out what is going on ... somebody have some idea?

@tjarratt
Copy link
Contributor

@rogerleite I appreciate all of the hard work you put in trying to debug this problem, as well as your honesty.

I was looking at this last night and it occurred to me that this error is very likely the same error that is causing our builds to fail on travis-ci. Will investigate more this week and see if I can track down the culprit.

@tjarratt
Copy link
Contributor

tjarratt commented Apr 2, 2014

@fjyaniez I think I found the root cause of the problem -- it's embarrassingly obvious in retrospect.

Net::HTTP is the default adapter for HTTPI. In JRuby 1.7, when using the ruby 2.0 engine, inflating compressed responses sometimes return an empty string. This is fairly easy to reproduce:

require 'net/http'

Net::HTTP.get("ec.europa.eu", "/taxation_customs/vies/checkVatService.wsdl")

The issue tracking this in the JRuby repo is jruby/jruby#1216 and it looks like it was just reported as fixed two hours ago.

@tjarratt tjarratt closed this as completed Apr 2, 2014
@fjyaniez
Copy link
Author

fjyaniez commented Apr 2, 2014

Great, thanks for your time and letting me know @tjarratt

@rogerleite
Copy link
Member

I'd never find this bug ... i swear that i saw this working on httparty.
Anyway, thanks @tjarratt for let us know!

@tjarratt
Copy link
Contributor

tjarratt commented Apr 2, 2014

@rogerleite -- to be fair, I led you astray. I implied that Net::HTTP worked, but it doesn't actually. It seems likely that HTTParty implements their own response parser, but I haven't actually investigated to see why HTTParty works but Net::HTTP doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants