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

PHP Fatal error in AbstractModelFile.php #181

Closed sunsetbeat closed 5 years ago

sunsetbeat commented 5 years ago

Hello,

when I run the script from the command line, I get the following error:

PHP Fatal error: Uncaught Error: Call to a member function getTypeStruct() on null in phar:///usr/local/bin/wsdltophp/src/File/AbstractModelFile.php:384 Stack trace:

0 phar:///usr/local/bin/wsdltophp/src/File/AbstractModelFile.php(392): WsdlToPhp\PackageGenerator\File\AbstractModelFile->getModelFromStructAttribute(NULL)

1 phar:///usr/local/bin/wsdltophp/src/File/Struct.php(606): WsdlToPhp\PackageGenerator\File\AbstractModelFile->getRestrictionFromStructAttribute(NULL)

2 phar:///usr/local/bin/wsdltophp/src/File/Struct.php(373): WsdlToPhp\PackageGenerator\File\Struct->getStructMethodsAddToAnnotationBlock(Object(WsdlToPhp\PhpGenerator\Element\PhpMethod))

3 phar:///usr/local/bin/wsdltophp/src/File/Struct.php(352): WsdlToPhp\PackageGenerator\File\Struct->getStructMethodAnnotationBlock(Object(WsdlToPhp\PhpGenerator\Element\PhpMethod))

4 phar:///usr/local/bin/wsdltophp/src/File/AbstractModelFile.php(301): WsdlToPhp\PackageGenerator\File\Struct->getMethodAnnotationBlock(Object(WsdlToPhp\PhpGenerator\Element\PhpMethod))

5 phar:/ in phar:///usr/local/bin/wsdltophp/src/File/AbstractModelFile.php on line 384

It's the content of the WSDL, as it does not show up at every WSDL.

can someone help me?

mikaelcom commented 5 years ago

Can you provide the WSDL?

sunsetbeat commented 5 years ago

wsdltophp generate:package --urlorpath="################DocumentsService.wsdl" --destination="./DocumentsService" --composer-name="midoco/documentsservice" --force

mikaelcom commented 5 years ago

Thanks, I'll look to it soon

mikaelcom commented 5 years ago

@Licciardi It should be fixed with the feature/issue-181 branch. Can you try?

Let me know,

sunsetbeat commented 5 years ago

Hallo @mikaelcom ,

is the update included in the "https://phar.wsdltophp.com/wsdltophp-php7.phar"?

I can execute this only in the command line.

mikaelcom commented 5 years ago

Try with one of these:

sunsetbeat commented 5 years ago

Hello, in the mentioned file everything worked now.

In the following I get now another error message:

wsdltophp generate:package --urlorpath="################BookingService.wsdl" --destination="./BookingService" --composer-name="midoco/bookingservice" --force

In Struct.php line 137: Unable to create function parameter for struct "customer" with type "'array'" for attribute "communication"

In AbstractElement.php line 35: Name "0" is invalid when instantiating PhpFunctionParameter object

generate:package [--force] [--urlorpath URLORPATH] [--destination DESTINATION] [--login [LOGIN]] [--password [PASSWORD]] [--proxy-host [PROXY-HOST]] [--proxy-port [PROXY-PORT]] [--proxy-login [PROXY-LOGIN]] [--proxy-password [PROXY-PASSWORD]] [--prefix PREFIX] [--suffix SUFFIX] [--namespace [NAMESPACE]] [--category [CATEGORY]] [--gathermethods [GATHERMETHODS]] [--gentutorial [GENTUTORIAL]] [--genericconstants [GENERICCONSTANTS]] [--addcomments [ADDCOMMENTS]] [--standalone [STANDALONE]] [--validation [VALIDATION]] [--struct [STRUCT]] [--structarray [STRUCTARRAY]] [--soapclient [SOAPCLIENT]] [--composer-name COMPOSER-NAME] [--composer-settings [COMPOSER-SETTINGS]] [--structs-folder [STRUCTS-FOLDER]] [--arrays-folder [ARRAYS-FOLDER]] [--enums-folder [ENUMS-FOLDER]] [--services-folder [SERVICES-FOLDER]] [--src-dirname [SRC-DIRNAME]] [--xsd-types-path [XSD-TYPES-PATH]] [--config [CONFIG]]

mikaelcom commented 5 years ago

It seems the WSDL contains both customer (in this xsd) and Customer (in this xsd) elements with both the same definitions containing respectively the Communication and communication property. So it won't work as you can't have two identical PHP classes with same name as PHP classes are always named with the first letter uppercase. The very first WSDL you mentionned is working by the way.

Is this normal to have both elements named with and without first-letter uppercase with a pretty-much same schema?

sunsetbeat commented 5 years ago

Hello, this is wanted by the operator.

Is there a possibility that I can exclude certain xsd files (in my case "################midoco-gds-message.xsd") for processing?

mikaelcom commented 5 years ago

The SoapClient does not allow to exclude/ignore an xsd file so it will be taken into account by the generator.

What I would do:

  1. Download locally the WSDL and its schema
  2. Remove the reference to the midoco-gds-message.xsd file from the xsd files
  3. Generate the SDK based on the local WSDL

I did not take time to look carefully to all the files so I don't know if any of the other xsd files needs declarations from this particular xsd.

Let me know then,

sunsetbeat commented 5 years ago

Hello,

Thanks, this worked now.

Result: We have now created a download script which has downloaded all files and removed the "midoco-gds-message.xsd". These files will now be processed successfully. The data from the "midoco-gds-message.xsd" are not needed. With the download script, this was now also fully automated.

Thanks for your help.

mikaelcom commented 5 years ago

fixed in 3.2.1 and 2.11.1