Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:19:56+00:00 2026-06-13T13:19:56+00:00

I have taken over an application from a previous developer, and there was some

  • 0

I have taken over an application from a previous developer, and there was some code which was half finished using Nusoap, I am getting the error:

Call to register_donation() web service failed due to an exception: 
Function ("register_donation") is not a valid method for this service   

The application is built on: CakePHP 1.2.10 & using nuSoap 0.9.5.

I have already ini_set('soap.wsdl_cache_enabled', 0); (This doesnt help.)

My code is below (I shortened it for readability), Am I processing this response correctly?
(The code was taken over by myself from a previous developer).

The Pastebin (of the full code) is here: PasteBin Link

A shortened version is below for a glance over, the full version is in the pastebin link above.

<?php
ini_set('soap.wsdl_cache_enabled', 0);

class ServicesController extends AppController
{
var $uses = array("Donation");
var $components = array( "Email", "MatchingEvents" );

function registerDonation($donation = null){
    $this->log('hit registerDonation', 'donation');
    $this->autoRender = false;
    App::import('Vendor','nusoap');
    Configure::write('debug',0);
    Configure::write('Session.start', false);

    //init soap server
    $server = new soap_server();

    $endpoint = 'http://new.mysite.com/services/registerDonation';

    //initialize WSDL support
    $server->configureWSDL('donations', 'urn:donations', $endpoint);

    //setup service type
    $server->wsdl->addComplexType(
        'DonationResult',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'success' => array('name' => 'success', 'type' => 'xsd:boolean'),
            'msg' => array('name' => 'msg', 'type' => 'xsd:string'),
            'error_number' => array('name' => 'error_number', 'type' => 'xsd:string')
        )
    );

    //register the method to expose
    $server->register('register_donation',
        array('ct_number' => 'xsd:string', 'project_id' => 'xsd:int', 'donation_amount' => 'xsd:decimal',
            // Stripped all other params
        ),
        array(
            'result' => 'tns:DonationResult'
        ),
        'urn:donations',
        'urn:donations#register_donation',
        'rpc',
        'encoded',
        'Accepts the results of a donation to a charity or project on the  site'
    );

    //This inner function is registered and then called (keep within outer function!)
    function register_donation(
        // Pass in all the params (Stripped for readability)
        $ct_number = null, $project_id = null, $donation_amount = null
    ){
        // This function is never hit!.. its not registered, why?
        $this->log('hit #3-register_donation called!', 'donation');
        $return = $this->Donation->add(array(
            'unique_id' => $unique_id,
            'ct_number' => $ct_number,
            'project_id' => $project_id,
            'donation_amount' => $donation_amount,
            // Pass in all other params, (Stripped for readability)
        ));

        // Process that request
        $log = $this->Donation->log . 'Result: ' . $return['msg'] . "\n";
        $this->log( $log, 'donation' );
        if ( isset($this->Donation->matching['events']) )
        {
            //Reserved donations should already have had their events handled
            $this->MatchingEvents->handle($this->Donation->matching, !$this->Donation->matching['reserved']);
        }
        if ( !empty($this->Donation->cacheSaved) )
            $this->_sendDonationEmails($this->Donation->cacheSaved);
        return $return;
    }

    $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
    $server->service($HTTP_RAW_POST_DATA);
}

function _sendDonationEmails($donation)
{
    // Send the emails
}
}

?>

If there is any more information I can provide, please let me know.

To Summarise: How do I process a nusoap response coming from a external source.
Any debugging ideas, hints & tips or solution will be rewarded (+1!).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:19:58+00:00Added an answer on June 13, 2026 at 1:19 pm

    In the code posted there’s a function named registerDonation inside a controller named ServicesController. Inside that function there is another function called register_donation (This obviously doesn’t make sense [Old Code]).

    Remove the function named register_donation out of the registerDonation method and place it as a method inside the ServicesContoller.

    Then change the following line (where you register the function to expose).

    From: $server->register('register_donation',
    To:     $server->register('ServicesController.register_donation',

    So you’re calling class.method as opposed to method only (This would work in PHP4 procedural programming, but in OOP, you need to specify the controller.method when exposing the function).


    Having other problems?

    Q: CakePHP & nuSOAP is not hitting my controller/method, but redirects to app/webroot
    A: Using CakePHP 1.2, I found when it did not have a services model (because it wasn’t
    technically required), The request does not hit the controller. So if you’re having this issue, create a model for your controller, even if you’re not using it. For your reference, here a modal example:

    <?php // You may not need this modal, but cakephp requires it to be there.
    class Services extends AppModel {
       public $name = 'Services';
       public $useTable = false;
    }
    ?>
    

    Q:What URL should I be receiving responses to?
    A: The URL you set your response to hit must include ?wsdl.
    So.. for eg: you have a controller named SOAPController and method named process.
    In CakePHP, your URL would look like this: mydomain.com/SOAP/process.
    So your WSDL is located at mydomain.com/SOAP/process?wsdl. Make sure your callback URL is set to this (including the wsdl).

    Q: How do I debug SOAP requests/responses using CakePHP?
    A: CakePHP has a logging feature which proved invaluable in debugging SOAP. In your controller (or modal) you can use:

    $this->log('your message or variable', 'name_of_file_to_save_to);
    

    You can use this through your SOAP request or response to see what parts are being hit/called and debugging variables (eg: $HTTP_RAW_POST_DATA).

    Q: My WSDL location is shown as `domain.com/app/webroot` when I visit the SOAP page.

    A: I thought this was the issue causing all the problems, Looking at the source code Nusoap uses PHP_SELF to get the current script (which in cakePHP is app/webroot/index.php), Don’t worry about this, you can access the wsdl by appending the URL with ?wsdl, This will show you your generated WSDL file, You don’t need to worry about fixing this. Its not interfering with your SOAP request whatsoever, It’s merely there for your convenience.

    Q: My SOAP address location is showing ‘domain.com/app/webroot/index.php`

    A: This was a issue I fixed by including the $endpoint in the configureWSDL().

    //Set our endpoint, Replace with your URL
    $endpoint = 'http://yourdomain.com/controller/method';
    
    //initialize WSDL support - Include the $endpoint.
    $server->configureWSDL('donations', 'urn:donations', $endpoint);
    
    // Now your Soap Address Location should be what you set as the $endpoint
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have taken over some code from a previous developer and have come across
So I've taken over a VB.net web application project from another developer and have
We have taken over some .NET 1.1 Windows Service code that spawns threads to
I've taken over a web application that is using Subversion. When the code is
I have taken over a project that was build from suggestions in this Dan
I have taken this little snippet straight out of some code I'm working on:
I have taken over a Windows-CE 6.0 application that I would like to port
I have taken over a medium sized project that was written originally using RoR.
I have taken over support of a web application and it includes a SOAP
There are many functions within the code I am maintaining which have what could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.