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

mncahill

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 10.0.10.116] 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/Lite.pm line 2896.


Request

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

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns8111:login xmlns:ns8111="http://10.126.34.86:8082/soap"><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>


Response

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="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Failed to locate method (login) in class (soap) at /usr/local/share/perl5/SOAP/Lite.pm line 2896.
</faultstring></soap:Fault></soap:Body></soap:Envelope>


Httpd conf:

Listen 443
SSLSessionCache none
NameVirtualHost <serveripremovedtopost>:443

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

<VirtualHost <serveripremovedtopost>:443>
    ServerName pd.dns.lycos.com
    ServerAlias dns.pd.lycos.com
    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
    </Files>

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

<IfDefine !MODPERL2>
   PerlFreshRestart On
</IfDefine>
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>
    <Location /soap>
        SetHandler perl-script
        PerlResponseHandler Apache::SOAP
        #PerlResponseHandler Apache2::SOAP
        PerlSetVar dispatch_to "/web/sites/NicToolServer/lib/NicToolServer, NicToolServer::SOAP"
    </Location>
</VirtualHost>



Any assistance greatly appreciated.

matt


mncahill

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/SOAP.pm line 13.  error - but that looks debuggable

mncahill

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

<?php 

$requestParams 
= 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);

print_r($result);

print_r($response);

$requestParams = array(
'nt_zone_id' => '',
'nt_group_id'=> '2',
'zone' => 'foobar.com',
'ttl' => '11111',
'nameservers' => '1,2',
 
'mailaddr' => 'webmaster@foobar.com',
'description' => 'a test zone created from API',
'nt_user_session' => $response->nt_user_session
);

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

print_r($result);

print_r($response);
?>