1

I have a drupal7 Site, in which I activated the services module to expose a SOAP service. The problem is that I set up everything, the endpoints, the handling of the request, load the WSDL and set the class to get th efunctions, but I always get an error

function tigoapi_server() {

require_once 'ServicePort.php';
global $HTTP_RAW_POST_DATA;
$server = new SoapServer(drupal_get_path('module', 'tigoapi') . '/wsdl/TigoAPIService_1.wsdl');
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL after the server is initiated
$server->setClass('ServicePort');

error_log(print_r($server->getFunctions(),true),3,"/var/www/sites/tigo/sites/all/modules/services/tigoapi/tigoapi.log");
$server->handle($HTTP_RAW_POST_DATA);

I always get:

curl http://server/tigoapi?wsdl
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad     Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope

Now, if I try it , same server, same WSDL, same ServicePort class, just not going throug the Drupal router it works:

    require_once 'ServicePort.php';
global $HTTP_RAW_POST_DATA;
//$server = new SoapServer(drupal_get_path('module', 'tigoapi') . '\wsdl\TigoAPIService_1.wsdl',array('encoding'=>'UTF-8'));   
$server = new SoapServer('wsdl/TigoAPIService_1.wsdl');
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL after the server is initiated
    $server->setClass('ServicePort');


    error_log(print_r($server->getFunctions(),true),3,"/var/www/sites/tigo/sites/all/modules/services/tigoapi/tigoapi.log");
//$server->handle();
$server->handle($HTTP_RAW_POST_DATA);

This works perfectly.

I'm using nginx and php-fpm, it would seem that the difference is in the way the requests gets here as with drupal I have a $_GET variable called 'q'

any ideas on this?

1

Ok it seems I'm implementing it wrong. The SoapServer::handle() source code shows why:

 if (SG(request_info).request_method &&
        strcmp(SG(request_info).request_method, "GET") == 0 &&
        SG(request_info).query_string &&stricmp(SG(request_info).query_string, "wsdl") == 0) {.....

the Get parameter must be wsdl, which Drupal rewrites. Also in essence using the SoapServer drupal module you get around this. references to implement this properly:

example More info Soap server module

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.