View Issue Details

IDProjectCategoryView StatusLast Update
0026492mantisbtapi soappublic2020-01-06 06:23
Reporterintervision Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version2.22.1 
Summary0026492: Object of class SoapFault could not be converted to int
Description

Somethihg strange with mc_issue_add.

I try to add new issue via soap api with PHP, so i describe variables like this:

    'project' => array (
      'id' => $ISSUE_PROJECT
    ),
    'category' => $ISSUE_CATEGORY,
    'reporter' => array (
      'id' => '$USER_ID',
    ),
    'summary' => $ISSUE_TITLE,
    'description' => $ISSUE_DESCR,

and so on...

But when i try to execute a request i got an error:

Array ( [faultcode] => SOAP-ENV:Server [faultstring] => Error Type: SYSTEM NOTICE, Error Description: Object of class SoapFault could not be converted to int )

So i don't know where this class came from, what is it and how to fix it...

TagsNo tags attached.

Activities

dregad

dregad

2019-12-24 09:23

developer   ~0063330

It is hard to give specific help, since you're not providing any details about the client code... I'm able to create issues via mc_issue_add() on my dev box without any problems.

SOAP API normally throws SoapFault exception when something goes wrong; the error could be client- or server-side. Are you catching the exception ? Then you can call getMessage() to learn more about why it failed.

Check your webserver's log for errors. You can also try setting $g_log_level = LOG_WEBSERVICE; and see if there's anything in MantisBT's log file on the server.

intervision

intervision

2019-12-24 10:25

reporter   ~0063331

Last edited: 2019-12-24 10:57

There are no errors in logs.
I am using NuSOAP library for client

The full part of code is this:

   $ISSUE_PROJECT = (int)$_POST['SelectProject'];
   $ISSUE_CATEGORY = $_POST['SelectCategory'];
   $ISSUE_TITLE = $_POST['Title'];
   $ISSUE_DESCR = $_POST['Description'];
   $ISSUE_EMAIL = $_POST['email'];

   $ISSUE_ARRAY = array (
        'project' => array (
          'id' => $ISSUE_PROJECT
        ),
        'category' => $ISSUE_CATEGORY,
        'reporter' => array (
          'id' => '2',
        ),
        'summary' => $ISSUE_TITLE,
        'description' => $ISSUE_DESCR,
      );

    $mc_issue_add = array (
        'username' => $USERNAME,
        'password' => $PASSWORD,
        'issue' => $ISSUE_ARRAY,
    );
    $client = new nusoap_client($WSDL_POINT, false);
    $new_issue = $client->call('mc_issue_add', $mc_issue_add, $WSDL_POINT);

    if ($client->fault) {
        echo '<p><b>FAULT: ';
        print_r($new_issue);
        echo '</b></p>';
    } else {
        $err = $client->getError();
        if ($err) {
            echo '<p><b>Error: ' . $err . '</b></p>';
        } else {
            print_r($new_issue);
        }
    }

EDIT (dregad) fix markdown

dregad

dregad

2019-12-24 10:57

developer   ~0063332

Is there any particular reason for using NuSOAP for the client ? We gave up on that long ago because the library was unmaintained and not supporting newer PHP versions, and switched to using native PHP SOAP extension.

Can you try with this snippet, see if that makes any difference in your environment ?

<?php
$u = ...;
$p = ...;
$h = 'http://localhost/mantis/api/soap/mantisconnect.php?wsdl';

$mantis = new soapclient($h);
$t_issue = array(
    'project' => array( 'id' => 1),
    'summary' => "Test Mantis-SOAP-API",
    'reporter' => array( 'id' => 1 ),
    'description' => "Test",
    'category' => 'General',
);

try {
    $result = $mantis->mc_issue_add($u, $p, $t_issue);
    var_dump($result);
} catch(SoapFault $e) {
    var_dump($e);
    exit(1);
}
intervision

intervision

2019-12-24 14:04

reporter   ~0063333

Last edited: 2019-12-24 14:06

Is there any particular reason for using NuSOAP for the client ?

Actually no ) I'm not a programmer so i tried to do what i need based on some manuals.
Some years ago the development of frontend called anonymantis was abandoned, so i decided to create my own (if you interest in it - https://github.com/intervisionlord/mantis-reporter )

I'll try your suggestion, please give me some time, thanks.

intervision

intervision

2019-12-24 14:27

reporter   ~0063334

Yes, your solution works fine, thanks a lot

dregad

dregad

2019-12-26 05:28

developer   ~0063339

Thanks for the feedback, glad I could help