PHP Classes

how to create wsdl for my simple class

Recommend this page to a friend!

      PHP WSDL Generator  >  All threads  >  how to create wsdl for my simple class  >  (Un) Subscribe thread alerts  
Subject:how to create wsdl for my simple class
Summary:how to create wsdl for my simple class
Messages:5
Author:mohammad moradpour
Date:2016-04-10 09:05:27
 

  1. how to create wsdl for my simple class   Reply   Report abuse  
Picture of mohammad moradpour mohammad moradpour - 2016-04-10 09:05:27
i am using this code for gerenate wsdl but it does not work

class MyAPI {

function hello() {
return "Hello";
}

}
$server = new SoapServer(NULL, array('uri'=>'http://localhost/wsdl_sample1.php?wsdl') );
$server->setClass('MyAPI');
$server->handle();


require_once('3/src/PHPClass2WSDL.php');

$class = "Vendor\\MyAPI";
$serviceURI = "http://localhost/wsdl_sample1.php?wsdl";

$wsdlGenerator = new PHPClass2WSDL($class, $serviceURI);
$wsdlGenerator->generateWSDL(true);
$wsdlXML = $wsdlGenerator->dump();

  2. Re: how to create wsdl for my simple class   Reply   Report abuse  
Picture of Protung Dragos Protung Dragos - 2016-04-10 12:29:35 - In reply to message 1 from mohammad moradpour
you have to annotate your code.

See https://github.com/dragosprotung/php2wsdl/blob/master/tests/Fixtures/DataProvider/TestMethodInputWithScalars.php as an example

  3. Re: how to create wsdl for my simple class   Reply   Report abuse  
Picture of Vector victor Vector victor - 2017-10-04 15:19:12 - In reply to message 2 from Protung Dragos
Hi!

I try to generate a simple wsdl with this script:

<?php
class MyAPI {
/**
* @param string $input Input.
*/
public function inputString($input)
{
}

}
require __DIR__ . '/vendor/autoload.php';
$class = "MyAPI";
$serviceURI = "http://localhost/test/soapserver/PHP2WSDLTest.php";
$wsdlGenerator = new PHP2WSDL\PHPClass2WSDL($class, $serviceURI);
$wsdlGenerator->generateWSDL(true);
$wsdlXML = $wsdlGenerator->dump();
?>

but I'm always getting null in $wsdlXML variable.
What shall I do to receive the wsdl?

Thanks

  4. Re: how to create wsdl for my simple class   Reply   Report abuse  
Picture of Protung Dragos Protung Dragos - 2017-10-04 15:36:29 - In reply to message 3 from Vector victor
Have a look at the tests as well

  5. Re: how to create wsdl for my simple class   Reply   Report abuse  
Picture of Vector victor Vector victor - 2017-10-05 11:30:48 - In reply to message 4 from Protung Dragos
Finally I found the key:
// Generate the WSDL from the class adding only the public methods that have @soap annotation.

Thanks!