background image

1.

<?

php

2.

class

 

SoapDiscovery

 

{

3.

private

 $class_name 

=

 

''

;

4.

private

 $service_name 

=

 

''

;

5.
6.

/**

7.

 * SoapDiscovery::__construct() SoapDiscovery class Constructor.

8.

 * 

9.

 * @param string $class_name

10.

 * @param string $service_name

11.

 **/

12.

public

 

function

 __construct

(

$class_name 

=

 

''

,

 $service_name 

=

 

''

)

 

{

13.

$this

->

class_name 

=

 $class_name

;

14.

$this

->

service_name 

=

 $service_name

;

15.

}

16.
17.

/**

18.

 * SoapDiscovery::getWSDL() Returns the WSDL of a class if the class 

is instantiable.

19.

 * 

20.

 * @return string

21.

 **/

22.

public

 

function

 getWSDL

()

 

{

23.

if

 

(

empty

(

$this

->

service_name

))

 

{

24.

throw

 

new

 

Exception

(

'No service name.'

);

25.

}

26.

$headerWSDL 

=

 

"<?xml version=\"1.0\" 

?>

\n";

27.

$headerWSDL.= "

<definitions

 

name

=

\"$this-

>

service_name\" targetNamespace=\"urn:$this->service_name\" 

xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" 
xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" 
xmlns:tns=\"urn:$this->service_name\" 
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-
ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" 
xmlns=\"http://schemas.xmlsoap.org/wsdl/\">\n";

28.

$headerWSDL.= "

<types 

xmlns

=

\"http://schemas.xmlsoap.org/wsdl/\"

 

/>

\n";

29.  
30.

if (empty($this->class_name)) {

31.

throw new Exception('No class name.');

32.

}

33.