Help with API - Failed to locate method (login) in class (soap)

Started by mncahill, November 21, 2013, 08:39:32 AM

Previous topic - Next topic


I've been pounding my head on the API for days.  I have yet to get a decent result from it.  Client is working fine.  I suspect issues with Soap::Lite

I'm seeing this error in my server log: [Thu Nov 21 10:22:57 2013] [error] [client] Handler for perl-script returned invalid result code 1

In my client (I have tried both nuSoap and standard soap clients with PHP - this is using nuSoap, due to debug capabilities):

[faultcode] => soap:Client
    [faultstring] => Failed to locate method (login) in class (soap) at /usr/local/share/perl5/SOAP/ line 2896.


POST /soap HTTP/1.0
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
Content-Length: 631

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="" xmlns:SOAP-ENV="" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC=""><SOAP-ENV:Body><ns8111:login xmlns:ns8111=""><nt_protocol_version xsi:type="xsd:string">1.0</nt_protocol_version><password xsi:type="xsd:string">domains</password><username xsi:type="xsd:string">root</username></ns8111:login></SOAP-ENV:Body></SOAP-ENV:Envelope>


HTTP/1.1 200 OK
Date: Thu, 21 Nov 2013 15:27:53 GMT
Server: Apache/2.2.15 (Scientific Linux)
Content-Length: 551
Content-Type: text/xml; charset=utf-8
SOAPServer: SOAP::Lite/Perl/1.08
Connection: close

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyle="" xmlns:soap="" xmlns:soapenc="" xmlns:xsd="" xmlns:xsi=""><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Failed to locate method (login) in class (soap) at /usr/local/share/perl5/SOAP/ line 2896.

Httpd conf:

Listen 443
SSLSessionCache none
NameVirtualHost <serveripremovedtopost>:443

PerlRequire /web/sites/NicToolClient/lib/nictoolclient.conf

<VirtualHost <serveripremovedtopost>:443>
    Alias /images/ "/web/sites/NicToolClient/htdocs/images/"
    DocumentRoot /web/sites/NicToolClient/htdocs
    ErrorLog /web/logs/dns/nictool_error_log
    DirectoryIndex index.cgi
    SSLEngine on
    SSLCertificateFile /web/sites/NicToolClient/certs/server.crt
    SSLCertificateKeyFile /web/sites/NicToolClient/certs/server.key

    <Files "*.cgi">
       SetHandler perl-script
       PerlResponseHandler ModPerl::Registry
       PerlOptions +ParseHeaders
       Options +ExecCGI

    <Directory "/web/sites/NicToolClient/htdocs">
        AllowOverride None
        Order allow,deny
        Allow from all

<IfDefine !MODPERL2>
   PerlFreshRestart On
PerlTaintCheck Off
Listen 8082

PerlRequire /web/sites/NicToolServer/lib/nictoolserver.conf

<VirtualHost *:8082>
    KeepAlive Off
    ErrorLog /web/logs/dns/nictool_server_error_log
    <Location />
        SetHandler perl-script
        PerlResponseHandler NicToolServer
    <Location /soap>
        SetHandler perl-script
        PerlResponseHandler Apache::SOAP
        #PerlResponseHandler Apache2::SOAP
        PerlSetVar dispatch_to "/web/sites/NicToolServer/lib/NicToolServer, NicToolServer::SOAP"

Any assistance greatly appreciated.



Thanks Matt!

I am a little further along - my SoapAction was incorrect - while it needs to make the request to http://ipaddresshere:8082/soap  the soap action is actually http://ipaddresshere/NicToolServer/SOAP#login which corresponds with my setup.

Now I've got a   [faultstring] => Can't use string ("domains") as a HASH ref while "strict refs" in use at /usr/local/share/perl5/NicToolServer/ line 13.  error - but that looks debuggable


My problems were coming from a few directions:

1. As noted above, difference between request uri and action
2. Using nuSoap introduced a lot of problems - stick to Php Soap function for client.

So, here is a very simple soap client with some notes in hopes others won't need to go through the intense debug I did


= array(
'nt_protocol_version' => '1.0',
'password' => 'some_password',
'username' => 'some_username'

//make sure you have the uri relative to your httpd perl dispatch setting.
$client = new SoapClient(null, array('location' => "http://ServerIpHere:8082/soap",
'uri'      => "http://serverIpHere/NicToolServer/SOAP"));
$response $client->login($requestParams);



$requestParams = array(
'nt_zone_id' => '',
'nt_group_id'=> '2',
'zone' => '',
'ttl' => '11111',
'nameservers' => '1,2',
'mailaddr' => '',
'description' => 'a test zone created from API',
'nt_user_session' => $response->nt_user_session

$response $client->new_zone($requestParams);