asmshaon / php-wsdl-creator

Automatically exported from code.google.com/p/php-wsdl-creator
GNU General Public License v3.0
0 stars 0 forks source link

php namespaced class error #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
For autoload purpose I have to use namespace for my web service classes. Things 
go well until I try to generate (Netbeans) a java client from the generated 
wsdl. 

I got bad elapsed character error due to the fact that phpwsdl put something 
like "\name\space\WSClass" for the service name. Java fail building a string 
from that. "\\name\\space\\WSClass" may work. 
But I think it will be better that phpwsdl put just the class name in the 
generated wsdl. i.e "WSClass" instead of "\name\space\WSClass".

Exemple namespaced ws code

<?php
namespace name\space;
// This bootstrapper may serve any SOAP webservice with PhpWsdl,
// if your methods and classes are commented. I developed and
// tested with Visual Studio 2010 and SoapUI 4.0.0. It seems to
// work pretty good...

// Include the demonstration classes
//require_once('class.WSClass.php');
require_once('class.complextype.php');

// Initialize the PhpWsdl class
require_once('class.phpwsdl.php');
\PhpWsdl::$UseProxyWsdl=false;
$soap = \PhpWsdl::CreateInstance(
    null,                               // PhpWsdl will determine a good namespace
    null,                               // Change this to your SOAP endpoint URI (or keep it NULL and PhpWsdl will determine it)
    null,                           // Change this to a folder with write access
    Array(                              // All files with WSDL definitions in comments
        'class.WSClass.php',
        'class.complextype.php'
    ),
    name\space\WSClass,                     // The name of the class that serves the webservice will be determined by PhpWsdl
    null,                               // This demo contains all method definitions in comments
    null,                               // This demo contains all complex types in comments
    false,                              // Don't send WSDL right now
    false);                             // Don't start the SOAP server right now

// Disable caching for demonstration
ini_set('soap.wsdl_cache_enabled',0);   // Disable caching in PHP
\PhpWsdl::$CacheTime=1;         // Disable caching in PhpWsdl

// Run the SOAP server
if($soap->IsWsdlRequested())            // WSDL requested by the client?
    $soap->Optimize=false;              // Don't optimize WSDL to send it human readable to the browser
//$soap->ParseDocs=false;               // Uncomment this line to disable the whole 
documentation features
//$soap->IncludeDocs=false;             // Uncomment this line to disable writing the 
documentation in WSDL XML
$wsdl = $soap->CreateWsdl();            // This would save the WSDL XML string in $wsdl
//$php=$soap->OutputPhp(false,false);   // This would save a PHP SOAP client as 
PHP source code string in $php
//$html=$soap->OutputHtml(false,false); // This would save the HTML 
documentation string in $html
$soap->RunServer(); 
?>

not working wsdl service part

<wsdl:service name="name\space\WSClass">
    <wsdl:port name="name\space\WSClassSoap" binding="tns:name\space\WSClassSoap">
        <soap:address location="http://localhost/test/name/space/WSClass.php"/>
    </wsdl:port>
</wsdl:service>

working wsdl service part (not well tested)

<wsdl:service name="WSClass">
    <wsdl:port name="WSClassSoap" binding="tns:WSClassSoap">
        <soap:address location="http://localhost/test/name/space/WSClass.php"/>
    </wsdl:port>
</wsdl:service>

Original issue reported on code.google.com by elomrayd...@gmail.com on 5 Apr 2012 at 4:40

GoogleCodeExporter commented 9 years ago
I add some code to 'class.phpwsdl.php' to make pwpwsdl output a wsdl file 
without namespaced class name but the resulting webservice failed to run. It 
says something like "can't find class 'WSClass'"; normal because php need the 
full namespace to load namespaced classes.
Can you help please?
I continue turning arrond by my side.

Original comment by elomrayd...@gmail.com on 6 Apr 2012 at 10:24

GoogleCodeExporter commented 9 years ago
Sorry for the big delay, I didn't receive the issue notice with email. I 
decided to add namespaces for PHP >=5.3 into the upcoming PhpWsdl version 3.0. 
Before that, version 2.4 will be released. Today someone told me that he would 
like to wrap the PhpWsdl code with namespaces for PHP 5.3 and the Symfony2 PHP 
framework. Maybe that would be a faster solution than waiting for PhpWsdl 
version 3.0. I'll add a link to this wrapper project, if it's going public.

Original comment by schickwa...@googlemail.com on 22 Aug 2012 at 8:48