Jump to content

error creating wsdl in a webservice


xuki

Recommended Posts

Hi every one!

 

I need your help to solve this problems.

I'm trying to creat a wsdl file to a webservice but i'm getting an erros.

 

"Error creating WSDL document:Error creating WSDL: no class found with the name 'array' / array : , so how should we know the structure for this datatype?"

 

now i will show u the code and hope someone discover the bug!

 

webservice.class.php

 

<?php

/**

* WebServices Handler

*

* This class will be used in the SOAP Server.

* To use all the available options on the SOAP Server we need to use

* a WSDL file.

*

* @author

* @version

* @package

*/

 

/**

* Classes needed to web service

*/

include_once("DB.class.php");

include_once("Maquinas.class.php");

 

/**

* ipTicketWS class

*

* This class has all methods to use on web service

* @package

*/

class ipTicketWS extends dbHandler

{

/**

* Set Maquinas info

*

* Function to get Maquinas info

* @param Integer $idmaquina maquinaID

* @return array of objects

*/

public function getMaquinas($idmaquina)

{

$res = new Maquina(array("db" => $this->__dbinfo));

return $res->getMaquinas($idmaquina);

}

 

 

}

 

?>

 

<?php

 

include_once ("DB.class.php");

 

class Maquina extends dbHandler

{

/** @var integer */

var $res;

var $tmp;

public $idmaquina;

 

public function __construct($__dbinfo, $idmaquina)

{

parent::__construct($__dbinfo);

$this->idatributo = $idmaquina;

}

 

 

public function getMaquinas($idmaquina)

{

$query = "select * from maquinas order by idmaquina";

$tmp = $this->dbHandlerquery($query);

return $tmp;

}

}

?>

 

DB.class.php

 

<?php

 

/**

* Database Handler Class

* HVasconcelos

*/

 

/**

* Class to handle all database communications

* @package dbHandler

*/

class dbHandler

{

/**

* Database Information

* @access public

* @var array

*/

public $__dbinfo = array ();

 

/**

* Debug Status

* @var boolean

*/

public $__debugStatus = false;

 

/**

* Logfile for Debug

* @var string

*/

public $__logfilename = "";

 

/**

* Handles DB open connection

*

* Options format:

* <code>

* $opts = array {

* "db" => array {

* "conn" => resource,

* "type" => 'POSTGRES', // MYSQL | ORACLE | POSTGRES

* },

* "debug" => true, // true|false

* "logfile" => '/tmp/dblog.log'

* }

* </code>

*

* @access public

* @param array $opts

* @return int

*/

public function __construct ( $opts = array () )

{

$this->__dbinfo['connected'] = ( ( $opts['db']['conn'] ) ? true : false );

$this->__dbinfo['conn'] = $opts['db']['conn'];

 

$this->__debugStatus = ( ( $opts['debug'] === true ) ? true : false );

$this->__logfilename = ( ( strlen ( $opts['logfile'] ) ) ? $opts['logfile'] : "" );

 

switch ( $opts['db']['type'] )

{

case 'MYSQL':

$this->__dbinfo['type'] = 'MYSQL';

break;

case 'ORACLE':

$this->__dbinfo['type'] = 'ORACLE';

break;

case 'POSTGRES':

$this->__dbinfo['type'] = 'POSTGRES';

break;

default:

$this->__dbinfo['type'] = 'POSTGRES';

break;

}

 

return $this->__dbinfo['connected'];

}

 

/**

* Parse DB results

* @access private

* @param object resource

* @return array of objects

*/

private function parseDBResults ( $res )

{

if (! $res ) {

return false;

}

 

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

 

$i = 0;

while ( $row = @oci_fetch_object ( $res ) ) {

foreach ( $row as $key => $value)

{

$row_object->{strtolower($key)} = $value;

}

$results[$i++] = $row_object;

}

 

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

 

$count = @pg_num_rows( $res );

$results = array ();

for ( $i = 0; $i < $count; $i++ ) {

$results[$i] = @pg_fetch_object ( $res, $i );

}

}

 

return $results;

}

 

/**

* Secure user data for SQL statements

* @access public

* @param array $args

* @return array Filtered arguments

*/

public function parseDBArrayArgs ( $args )

{

$safeArgs = array ();

 

$count = count ( $args );

for ( $i = 0; $i < $count; $i++ ) {

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

$safeArgs[$i] = @pg_escape_string ( $args[$i] );

}

}

 

return $safeArgs;

}

 

/**

* Secure user data for SQL statements

* @access public

* @param string $arg

* @return string Filtered string

*/

public function parseDBStringArg ( $arg )

{

$safeStr = "";

 

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

$safeStr = @pg_escape_string ( $arg );

}

 

return $safeStr;

}

 

/**

* Handles DB query (SQL SELECT)

* @access public

* @param string $sql

* @return array Object resource | false

*/

public function dbHandlerquery ( $sql )

{

$res = false;

 

 

if ( $this->__dbinfo['connected'] === true ) {

 

$this->__debug ( "(QUERY) " . htmlentities ( $sql ) );

 

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

 

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

 

$res = @oci_parse ( $this->__dbinfo['conn'], rtrim ( $sql, ';' ) );

$resource = @oci_execute ( $res );

 

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

$res = @pg_query ( $sql );

}

 

if (! $res) {

$this->__debugLastDBError ();

}

 

} else {

$this->__debug ( "There's no database connection..." );

}

 

return $this->parseDBResults ( $res );

}

 

/**

* Handles DB execute (SQL UPDATE | INSERT | DELETE )

* @access public

* @param string $sql

* @return array Object resource | false

*/

public function dbHandlerexecute ( $sql )

{

$res = false;

 

if ( $this->__dbinfo['connected'] === true ) {

 

$this->__debug ( "(QUERY) " . htmlentities ( $sql ) );

 

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

 

$res = @oci_parse ( $this->__dbinfo['conn'], rtrim ( $sql, ';' ) );

$resource = @oci_execute ( $res );

 

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

$res = @pg_query ( $sql );

}

 

if (! $res) {

$this->__debugLastDBError ();

}

 

} else {

$this->__debug ( "There's no database connection..." );

}

 

return $res;

}

 

/**

* Prints Database Information

* @access public

* @param void

* @return void

*/

public function __prtDBInfo ( )

{

echo "<pre>";

var_dump ( $this->__dbinfo );

var_dump ( $this->__debugStatus );

var_dump ( $this->__logfilename );

echo "</pre>";

}

 

/**

* Generic Debug Function

*

* Inserts timestamp in the debug string.

* Timestamp format: YYYMMDDHHMMSS

*

* @access private

* @param string $dbgStr

* @return void

*/

private function __debug ( $dbgStr )

{

if ( $this->__debugStatus === true ) {

echo "<pre>DBGSTR: $dbgStr</pre>";

$this->__debug2Logfile ( $dbgStr );

}

}

 

/**

* Debug Database Communications

* @access private

* @param void

* @return void

*/

private function __debugLastDBError ( )

{

if ( $this->__debugStatus === true ) {

 

if ( $this->__dbinfo['type'] == 'MYSQL' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'ORACLE' ) {

// ...

} else if ( $this->__dbinfo['type'] == 'POSTGRES' ) {

$dbgStr = @pg_last_error ( $this->__dbinfo['conn'] );

$this->__debug2Logfile ( $dbgStr );

echo "<pre>DBGSTR: $dbgStr</pre>";

}

}

}

 

/**

* Debug Database Communications to Logfilename

*

* Inserts timestamp in the debug string.

* Timestamp format: YYYMMDDHHMMSS

*

* @access private

* @param string $dbgStr

* @return void

*/

private function __debug2Logfile ( $dbgStr )

{

if ( ( $this->__debugStatus === true ) && ( $this->__logfilename ) ) {

$tstamp = date ( "YmdHis" );

@error_log ( $tstamp." - " . $dbgStr . "\n", 3, $this->__logfilename );

}

}

}

 

?>

 

 

I think the error is somewhere here but i can't find it. Hope u con help me!

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/195425-error-creating-wsdl-in-a-webservice/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.