WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
422 stars 73 forks source link

Issue with Tutorial #22

Closed kevinmlong closed 9 years ago

kevinmlong commented 9 years ago

So I was able to get the package to build. If I try to run the tutorial, it throws an exception saying it cannot find the class, which happens to be one of the classes generated by the package generator...

I'm sure it's something obvious I'm missing...

Thoughts?

kevinmlong commented 9 years ago

So - this probably has to do with the lack of autoload file. Looks like you and this before. Is this coming back?

mikaelcom commented 9 years ago

How did you generate the package? Can you indicate the used options?

Normally, composer is launched in the genererated package folder in order to get the dependency package and generate the autoload. Did it happen? On which OS are you? Did you have any error during the generation?

kevinmlong commented 9 years ago

I'm doing this on MacOSX. No errors during build/package generation, but no autoload file is generated.

kevinmlong commented 9 years ago

Console out put while generating:

Start at 2015-08-21 07:09:16
Loading composer repositories with package information
Updating dependencies
Analyzed 70 packages to resolve dependencies
Analyzed 65 rules to resolve dependencies
  - Installing wsdltophp/packagebase (dev-master 3ccda03)
    Cloning 3ccda031051d088811f59d930e6e8d882ba49080

Writing lock file
Generating optimized autoload files
 End at 2015-08-21 07:09:32, duration: 00:00:16

Directory structure after complete

├── EnumType
│   ├── << FILES >>
├── ServiceType
│   ├── << FILES >>
├── StructType
│   ├── << FILES >>
├── TESTClassMap.php
├── composer.json
├── composer.lock
├── tutorial.php
└── vendor
    ├── autoload.php
    ├── composer
    │   ├── ClassLoader.php
    │   ├── LICENSE
    │   ├── autoload_classmap.php
    │   ├── autoload_namespaces.php
    │   ├── autoload_psr4.php
    │   ├── autoload_real.php
    │   └── installed.json
    └── wsdltophp
        └── packagebase
            ├── CHANGELOG.md
            ├── LICENSE
            ├── README.md
            ├── composer.json
            ├── phpunit.xml.dist
            ├── src
            │   ├── AbstractSoapClientBase.php
            │   ├── AbstractStructArrayBase.php
            │   ├── AbstractStructBase.php
            │   ├── SoapClientInterface.php
            │   ├── StructArrayInterface.php
            │   ├── StructInterface.php
            │   └── Utils.php
            └── tests
                ├── Client.php
                ├── SoapClient.php
                ├── SoapClientTest.php
                ├── StructArrayObject.php
                ├── StructArrayTest.php
                ├── StructBaseTest.php
                ├── StructObject.php
                ├── TestCase.php
                ├── UtilsTest.php
                └── resources
                    ├── bingsearch.wsdl
                    ├── formated.xml
                    └── oneline.xml

Error seen when checking out tutorial

>>>php tutorial.php
PHP Fatal error:  Class 'TEST\TESTClassMap' not found in /path/to/package/pkg-test/tutorial.php on line 22
ceeram commented 9 years ago

The autoload file is there:

└── vendor
    ├── autoload.php
kevinmlong commented 9 years ago

I see that it's there, but why do I get the error when executing php tutorial.php?

ceeram commented 9 years ago

i mentioned this here: https://github.com/WsdlToPhp/PackageGenerator/issues/13#issuecomment-126513404

also includes how to fix it

kevinmlong commented 9 years ago

Appreciate the insight! That worked like a charm. Suggest this be added to the README file so that others don't run into the same trap.

Thanks again!

ceeram commented 9 years ago

did that already as well in same thread: https://github.com/WsdlToPhp/PackageGenerator/issues/13#issuecomment-126516465

mikaelcom commented 9 years ago

@ceeram: I believe it can't be done using the init command using composer, isn't it? (as a reminder, the generated composer file is generated using the composer package/dependency).

If the autoload section can't be added using the init composer's command then it means I'll have to generate the composer file another way. Any suggestion?

ceeram commented 9 years ago

I think its possible, but i had some other ideas in mind as well, which would probably make things a bit easier as well. Ill put up a PR for those to discuss them.

EDIT: Seems not possible with composer commands

kevinmlong commented 9 years ago

So... I have another question...

It seems that the generated classes don't support elements that also have a value. Example:

namespace TEST\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for GloballyUniqueFlightIdentifierType StructType
 * @package TEST
 * @subpackage Structs
 */

class TESTGloballyUniqueFlightIdentifierType extends AbstractStructBase
{
    /**
     * The codeSpace
     * @var string
     */
    public $codeSpace;
    /**
     * Constructor method for GloballyUniqueFlightIdentifierType
     * @uses TESTGloballyUniqueFlightIdentifierType::set_()
     * @uses TESTGloballyUniqueFlightIdentifierType::setCodeSpace()
     * @param string $codeSpace
     */
    public function __construct($codeSpace = null)
    {
        $this
            ->setCodeSpace($codeSpace);
    }

    /**
     * Get codeSpace value
     * @return string|null
     */
    public function getCodeSpace()
    {
        return $this->codeSpace;
    }
    /**
     * Set codeSpace value
     * @param string $codeSpace
     * @return \TEST\StructType\TESTGloballyUniqueFlightIdentifierType
     */
    public function setCodeSpace($codeSpace = null)
    {
        $this->codeSpace = $codeSpace;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \TEST\StructType\TESTGloballyUniqueFlightIdentifierType
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}

the element send to the web service should look like

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="----">
   <soapenv:Header/>
   <soapenv:Body>
      <def:Gufi codeSpace="urn:uuid">b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad</def:Gufi>
   </soapenv:Body>
</soapenv:Envelope>

How do I set the b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad?

ceeram commented 9 years ago

Pass it to the constructor? Op 21 aug. 2015 16:21 schreef "kevinmlong" notifications@github.com:

So... I have another question...

It seems that the generated classes don't support elements that also have a value. Example:

namespace TEST\StructType;use \WsdlToPhp\PackageBase\AbstractStructBase;/* * This class stands for GloballyUniqueFlightIdentifierType StructType * @package TEST * @subpackage Structs /class TESTGloballyUniqueFlightIdentifierType extends AbstractStructBase{ /* * The codeSpace * @var string / public $codeSpace; /* * Constructor method for GloballyUniqueFlightIdentifierType * @uses TESTGloballyUniqueFlightIdentifierType::set() * @uses TESTGloballyUniqueFlightIdentifierType::setCodeSpace() * @param string $codeSpace / public function _construct($codeSpace = null) { $this ->setCodeSpace($codeSpace); } /* * Get codeSpace value * @return string|null / public function getCodeSpace() { return $this->codeSpace; } /* * Set codeSpace value * @param string $codeSpace * @return \TEST\StructType\TESTGloballyUniqueFlightIdentifierType / public function setCodeSpace($codeSpace = null) { $this->codeSpace = $codeSpace; return $this; } /* * Method called when an object has been exported with var_export() functions * It allows to return an object instantiated with the values \ @see AbstractStructBase::set_state() * @uses AbstractStructBase::setstate() * @param array $array the exported values * @return \TEST\StructType\TESTGloballyUniqueFlightIdentifierType / public static function set_state(array $array) { return parent::setstate($array); } /* * Method returning the class name * @return string CLASS */ public function toString() { return __CLASS; }}

the element send to the web service should look like

soapenv:Header/ soapenv:Body b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad/def:Gufi /soapenv:Body /soapenv:Envelope How do I set the b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad? — Reply to this email directly or view it on GitHub https://github.com/WsdlToPhp/PackageGenerator/issues/22#issuecomment-133440724 .
kevinmlong commented 9 years ago

Not quite... I don't think these classes support setting the value of the element. All of the variables defined in the class are attributes I believe. Am I wrong?

ceeram commented 9 years ago

is this a public soap service? can you provide the wsdl location? need more context to see i guess, unless @mikaelcom can tell from the top off the head

kevinmlong commented 9 years ago

Unfortunately it's not. This is what the library generates:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="----">
  <SOAP-ENV:Body>
    <ns1:Gufi codeSpace="urn:uuid"/>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is what I need it to look like (generated with SoapUI):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="----">
   <soapenv:Header/>
   <soapenv:Body>
      <def:Gufi codeSpace="urn:uuid">b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad</def:Gufi>
   </soapenv:Body>
</soapenv:Envelope>

My question pertains to how to populate the b2b50566-f8ae-4ecf-b4a8-d9bb3fc5d6ad as adding another variable to the class just adds another attribute.

kevinmlong commented 9 years ago

So I figured it out. Mainly an error on my part for changing some stuff and forgetting that I did that. I have it properly working now, with the exception that I get a SOAP-ERROR: Encoding: Violation of encoding rules during the call $this->setResult(self::getSoapClient()->method($params));

The request works fine in SoapUI

Thoughts?

mikaelcom commented 9 years ago

@kevinmlong could you send me the WSDL and its associated schema to contact@wsdltophp.com.

Normally, the _ property is defined as the value but it seems the getter/setter are not defined nor called even if the constructor PHPDoc indicated its calls it at @uses TESTGloballyUniqueFlightIdentifierType::set_()

thanks

mikaelcom commented 9 years ago

Autoload is now fixed on develop branch since https://github.com/WsdlToPhp/PackageGenerator/commit/081efaef595aa72500a83d2a9d8988bd3f558618.

@kevinmlong could you send me the WSDL and its associated schema to contact@wsdltophp.com? I won't make it public in any way, I'm just curious about your issue, thks

kevinmlong commented 9 years ago

@mikaelcom - unfortunately I can't - sorry. Apologies for not posting my comment earlier. The encoding issue was a php config issue I believe. By updating my php version (or using the MAMP installation) resolved this error.

mikaelcom commented 9 years ago

@kevinmlong OK, good to know. This issue is no longer existing then? Can it be closed?

mikaelcom commented 9 years ago

@kevinmlong any additional feedback in mind?

mikaelcom commented 9 years ago

no news good news :smile: