Menu

#4 php namespaced class error

Started
nobody
None
Medium
Enhancement
2012-08-22
2012-04-05
Anonymous
No

Originally created by: elomrayd...@gmail.com
Originally owned by: schickwa...@googlemail.com

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](https://code.google.com/p/php-wsdl-creator/wiki/PhpWsdl)::$UseProxyWsdl=false;
$soap = [PhpWsdl](https://code.google.com/p/php-wsdl-creator/wiki/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](https://code.google.com/p/php-wsdl-creator/wiki/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>

Discussion

  • Anonymous

    Anonymous - 2012-04-06

    Originally posted by: elomrayd...@gmail.com

    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.

     
  • Anonymous

    Anonymous - 2012-08-22

    Originally posted by: schickwa...@googlemail.com

    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.

    Labels: -Type-Defect Type-Enhancement
    Owner: schickwa...@googlemail.com
    Status: Started

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.