Search code examples
ruby-on-railsweb-servicessoapsavon

How to solve this error " (pre:svcFault) Service Fault"?


I am trying to call a SOAP api using Savon gem. I am getting the following error: "(pre:svcFault) Service Fault" error image I created both the header and message for the request. Here is the request sent from SoapUI: SoapUI request. i am getting a true response from SoapUI. My code is shown below:

class SoapApi
    require 'savon'
    def self.initialize 
        header = {
            "ebmCID" => "9366498d-bc79-4fad-be2b-fa1a0e84241a", 
            "ebmMID" => "9366498d-bc79-4fad-be2b-fa1a0e84241a",
            "ebmRTID" => "9366498d-bc79-4fad-be2b-fa1a0e84241a",
            "ebmSID" => "FMobile-FCUBS",
            "ebmTimestamp" => "2019-06-10T12:27:46.1623586Z",
        }
        message = { 
            customerId: '00653473'
        }
        client = Savon.client(
                    :wsdl => "https://192.168.176.103:8012/tevs/pp.pm.evs.Customer_1.2?wsdl",
                    :ssl_verify_mode => :none
                    )
        response = client.call(
                    :get_account_list,
                    :soap_header => header, 
                    :message => message
                    )
        return response
    end
end

And here i am calling the above method:

#index.html.erb
<%=
  SoapApi.initialize
  puts @response 
%>

Solution

  • Where you able to create a valid call using SoapUI (https://www.soapui.org.)? Try this first and make it work. Next create a call from a plain ruby script - without Rails - which sends the same functional XML as you did in SoapUI before. Third embed this code into your RoR application.

    You can put the following in your client definition for better logging:

    client = Savon.client(
      :wsdl => "https://192.168.176.103:8012/tevs/pp.pm.evs.Customer_1.2?wsdl",
               :ssl_verify_mode => :none,
        log: true,
        log_level: :debug,
        pretty_print_xml: true
        )
    

    Compare the output with your working SoapUI example.