soap4r authentication error

211 views Asked by At

I am using soap4r with ruby 1.8.7p358 and I am facing a strange error. I have an endpoint_url, when I browse it, there is no authentication error message. It prints out the response. However, when I create a soap client and try to access the method of the client, it gives me authentication error.

For instatance: I have a url (say) endpoint_url.com/api/get_name.php?user_name="test"&api_key="test" This link gives me response like

<response>
<result>
<success>1</success>
</result>
<userspage="1" numberofpages="1" numberofusers="1"><row>Sadiksha</row>
</domains>
</response>

I initialize the rpc driver as

  def initialize
    @username = "test"
    @apikey = "test"
    @driver = SOAP::RPC::Driver.new("endpoint_url.com/api/get_name.php", "urn:UserDetails")
  end

I have a method in the same file that gets all the statistics of user

  def getStats (name)
      @driver.add_method('GetDetails', 'name')
      user_details = {
      'user_name' => @username,
      'api_key' => @apikey, 
      'name' => name
    } 
    result = @driver.GetDetails(user_details)
    return result 
  end

When I run the program it gives me error "Your username & apikey were not recognised!" I have been looking at it for a sometime now. But, I really cannot figure out what might be wrong! Can anyone please let me know what I am doing wrong here!

0

There are 0 answers