Fatal error: Uncaught SoapFault exception: [100]

shifty_ 28 Sep, 2011
Hi There

I know nothing about SOAP, but my client has a 3rd party that have contacted me asking me to paste in some PHP code that will initiate a SOAP call when someone submits the form.

The only spot I can think of doing that is in the "On Submit Code" box - either before or after email wouldn't really matter.

But when I paste thier code (which is apparently tried and tested on other sites) it breaks it when I submit the form with an error that I can't find any help on:

Fatal error: Uncaught SoapFault exception: [100] Access denied in /home/xxxxxxxx/public_html/components/com_chronocontact/libraries/customcode.php(64)

Can anybody point me in the right direction? Should I put that code in the On Submit Section? Or is there somewhere else I should be putting it? Or anyone know what that error means?

Here is a sample of the SOAP code:


$apiKey = " xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$campaignID = " xxxx0000";
  
$client = new SoapClient("http://api.xxxxx.com/wsdl", array("trace" => true));
$result = $client->Campaign_trigger(array(
        "apikey" => $apiKey,
        "camp_id" => $campaignID,
        "record" => Array("columns" =>
             Array(
                 Array(
                     "field_name" => "Name",
                     "field_value" => "Rodney Tester"
                 ),
                 Array(
                     "field_name" => "email",
                     "field_value" => "rodtester@gmail.com"
                 )
             )
        )
));


Cheers

Shifty_
GreyHead 28 Sep, 2011
Hi shifty_,

What is on line 64 of the Custom Code block?

Bob
nml375 28 Sep, 2011
Hi shifty_,
The exception is most likely thrown on the remote end. My first guess would be that the api-key or campaign-ID is mis-spelled or such.

You could try and investigate the SoapFault exception (using try/catch) for further details, though this would depend on what details the Soap interface provides during the exception.

try {
  $client = new SoapClient(...);
  $result => $client->Campain_trigger(....);

  if (is_soap_fault($result))
  {
    echo('<pre>');
    print_r($result);
    echo('</pre>');
  }
} catch(Exception $e) {
  echo('<pre>');
  print_r($e);
  echo('</pre>');
}


/Fredrik
shifty_ 29 Sep, 2011
Hi Guys, thanks for your responses.

GreyHead, this is line 64 in that file:


eval( "?>".$MyForm->formrow->onsubmitcodeb4 );


And Fredrik, I will verify all of the fields and try again.

Not exactly sure what to do with that code you have included above though... Do I just copy and paste that as is in to the OnSubmit Code box?
shifty_ 29 Sep, 2011
Hi Fredrik, spot on!! I had a space before my apiKey and campaignID (as that was how they emailed it to me), but when I took them out it started working... Sorry to bother you both with a problem completely un-related to ChronoForms.

Awesome support for an awesome product... Thanks again.
nml375 29 Sep, 2011
Hi,
Happy to hear you got it sorted. In most cases, these errors are due to a serverside exception, or an incorrect parameter array.

Just for reference, the code I posted earlier would be an example on how to wrap your Soap-code with a try/catch block to handle exceptions (and in this example, post some debug content on the page). I left out the wsdl-contract URI and request parameters array to avoid bloating the post, so you'd have to replace all the .... in there.
Simply put, you put all your code inside the "try" block, and add some logging in the "catch" block.

/Fredrik
This topic is locked and no more replies can be posted.