Code Monkey home page Code Monkey logo

wsdl2phpgenerator's Introduction

wsdl2phpgenerator

Latest Stable Version Build Status Code Coverage Scrutinizer Quality Score Dependency Status

Simple WSDL to PHP classes converter. Takes a WSDL file and outputs class files ready to use.

Uses the MIT license.

Maintenance status

This is no longer actively maintained.

If you are looking for a PHP library to work with SOAP, you might want to try phpro/soap-client.

If you are currently using wsdl2phpgenerator and want to continue using it, consider forking the project and maintain it yourself.

New major version: 3

A new major version of wsdl2phpgenerator has recently been released: 3

This introduces changes to both configuration and generated code. The changes makes it more flexible to use, easier to include in other projects, promotes contributions and reduces maintenance.

2.x users are encourage to read a walkthrough of what is new in 3.0.

Installation

Add wsdl2phpgenerator to your project using composer:

composer require wsdl2phpgenerator/wsdl2phpgenerator

Contributors

Originally developed by @walle and includes bug fixes and improvements from various contributors.

Contributing

Pull requests are very welcome. Please read our guidelines for contributing.

Be sure to run the test suite, the fixers and the analyzers

composer test
composer fix
composer analyse

Usage and options

See usage and options for info on the usage of this package.

Versioning

This project uses semantic versioning. The following constitutes the public API:

  • \Wsdl2PhpGenerator\GeneratorInterface
  • \Wsdl2PhpGenerator\ConfigInterface
  • Generated code

Backwards incompatible changes to these means that the major version will be increased. Additional features and bug fixes increase minor and patch versions.

wsdl2phpgenerator's People

Contributors

chriskl avatar devlead avatar ecolinet avatar fduch avatar garex avatar gisostallenberg avatar honzap avatar ivol84 avatar jabiinfante avatar jk avatar jongotlin avatar joshk avatar jrbasso avatar kasperg avatar lafriks avatar lunetics avatar methodin avatar nuth avatar red-led avatar renatomefi avatar rsully avatar sammousa avatar sheeep avatar statik-olmo-archived avatar trycatchjames avatar vtsao avatar walle avatar xoeoro avatar xstefanox avatar yuav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsdl2phpgenerator's Issues

Exceptions created as regular classes, not extending Exception

for example

class ViaApiServiceServiceCartNotFoundException
{

/**

  • @var CartNotFoundException $CartNotFoundException

  • @access public
    */
    public $CartNotFoundException = null;

    /**

  • @param CartNotFoundException $CartNotFoundException

  • @access public
    */
    public function __construct($CartNotFoundException)
    {
    $this->CartNotFoundException = $CartNotFoundException;
    }

}

created from

<soap:fault use="literal" name="ViaApiServiceServiceCartNotFoundException"/>

Error processing WSDL: Call to a member function getElementsByTagName() on a non-object

I execute this command:

./wsdl2php -v -s -i http://demo.yourzephyr.com/flex/services/soap/zephyrsoapservice-v1?wsdl -o /opt/wsdl2phpgenerator1.4.1-php5.3/scripts/

I'm running into the following error:
Fatal error: Call to a member function getElementsByTagName() on a non-object in /opt/wsdl2phpgenerator1.4.1-php5.3/src/Generator.php on line 373

Starting generation
Loading the wsdl
Loading the DOM
Loading types
Loading type getRequirementsByCriteria
Loading type remoteCriteria
Loading type getRequirementsByCriteriaResponse
Loading type remoteRequirement
Loading type remoteCustomizableEntity
Loading type customProperties
Loading type entry
Loading type getAttachmentsByCriteria
Loading type getAttachmentsByCriteriaResponse
Loading type remoteAttachment
Loading type addPhaseToCycle
Loading type remotePhase
Loading type remoteNameValue
Loading type remoteData
Loading type addPhaseToCycleResponse
Loading type getProjectsByCriteria
Loading type getProjectsByCriteriaResponse
Loading type remoteProject
Loading type remoteDepartment
Loading type remoteOrganization
Loading type member
Loading type getRequirementTreesByCriteria
Loading type getRequirementTreesByCriteriaResponse
Loading type remoteRequirementTree
Loading type login
Loading type loginResponse
Loading type deallocateRequirementTreesFromRelease
Loading type deallocateRequirementTreesFromReleaseResponse
Loading type allocateRequirementsToRelease
Loading type allocateRequirementsToReleaseResponse
Loading type mapTestcasesToRequirement
Loading type mapTestcasesToRequirementResponse
Loading type createNewTestcaseTree
Loading type remoteRepositoryTree
Loading type remoteRepositoryChild
Loading type createNewTestcaseTreeResponse
Loading type deleteRequirementTreeById
Loading type deleteRequirementTreeByIdResponse
Loading type updateTestcase
Loading type remoteFieldValue
Loading type updateTestcaseResponse
Loading type deleteAttachmentsByCriteria
Loading type deleteAttachmentsByCriteriaResponse
Loading type getTestcaseTreeById
Loading type getTestcaseTreeByIdResponse
Loading type getTestCaseTreesByCriteria
Loading type getTestCaseTreesByCriteriaResponse
Loading type updateRequirementTree
Loading type updateRequirementTreeResponse
Loading type assignTestSchedules
Loading type remoteReleaseTestSchedule
Loading type testResult
Loading type defect
Loading type assignTestSchedulesResponse
Loading type mapRequirementsToTestcase
Loading type mapRequirementsToTestcaseResponse
Loading type updateRequirement
Loading type updateRequirementResponse
Loading type updateTestStatus
Loading type remoteTestResult
Loading type updateTestStatusResponse
Loading type getCustomFields
Loading type getCustomFieldsResponse
Loading type remoteCustomField
Loading type getTestSchedulesByCriteria
Loading type getTestSchedulesByCriteriaResponse
Loading type getAllRequirementsByTestcaseId
Loading type getAllRequirementsByTestcaseIdResponse
Loading type getTestcaseById
Loading type getTestcaseByIdResponse
Loading type remoteRepositoryTreeTestcase
Loading type remoteTestcase
Loading type remoteDefect
Loading type getRequirementTreeById
Loading type getRequirementTreeByIdResponse
Loading type createNewCycle
Loading type remoteCycle
Loading type createNewCycleResponse
Loading type getReleaseById
Loading type getReleaseByIdResponse
Loading type remoteRelease
Loading type getProjectById
Loading type getProjectByIdResponse
Loading type getCyclesByCriteria
Loading type getCyclesByCriteriaResponse
Loading type getAttachmentById
Loading type getAttachmentByIdResponse
Loading type createNewTestcase
Loading type createNewTestcaseResponse
Loading type allocateRequirementTreeToRelease
Loading type allocateRequirementTreeToReleaseResponse
Loading type getTestcasesByCriteria
Loading type getTestcasesByCriteriaResponse
Loading type deleteRequirementById
Loading type deleteRequirementByIdResponse
Loading type deallocateRequirementsFromRelease
Loading type deallocateRequirementsFromReleaseResponse
Loading type createNewRequirement
Loading type createNewRequirementResponse
Loading type getUserById
Loading type getUserByIdResponse
Loading type remoteUser
Loading type remoteRole
Loading type getUsersByCriteria
Loading type getUsersByCriteriaResponse
Loading type getRequirementById
Loading type getRequirementByIdResponse
Loading type addAttachments
Loading type addAttachmentsResponse
Loading type deleteAttachmentById
Loading type deleteAttachmentByIdResponse
Loading type logout
Loading type logoutResponse
Loading type getTestSchedulesById
Loading type getTestSchedulesByIdResponse
Loading type getCycleById
Loading type getCycleByIdResponse
Loading type createNewRequirementTree
Loading type createNewRequirementTreeResponse
Loading type updateAttachment
Loading type updateAttachmentResponse
Loading type getReleasesByCriteria
Loading type getReleasesByCriteriaResponse

Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/zephyr/installers/wsdl2phpgenerator1.4.1-php5.3/src/Generator.php on line 373

Decouple everything from singleton

It would be nice if something like ComplexType would have an injected config object, rather than depending on the generator's global config, which can only be set by actually calling the generate method. This allows each piece to be used independently.

Composer install exception for kherge/Amend

I've got this exception during composer installation (v2.3.0).

The "https://api.github.com/repos/kherge/Amend/zipball/d191de606b3b76a28f09d97ddc04014426116965" file could not be downloaded (HTTP/1.1 404 Not Found)

After that i've added composer require kherge/amend=3.* and that solved the problem.

Make one branch

Create a branch without namespaces since they are pretty much the only thing that brakes 5.2 support in the 5.3 branch.

But don't use the horrid prefixes that are in the 5.2 branch.

Operations assumed array

PHP Warning: Invalid argument supplied for foreach() in /Projects/Dev/project/vendor/wsdl2phpgenerator/wsdl2phpgenerator/src/Wsdl2PhpGenerator/Service.php on line 142

I am experimenting with some non-standard WSDLs. This one has no operations listed.

I'll try to address this in a PR.

Operation::getParamString() returns faulty PHP in some cases.

A method on the service object was generated with a faulty signature:

public function Login(Login Login $parameters)

This can be fixed by adding a break in Operation::getParamString():

            if ($typeHint == $type->getPhpIdentifier())
            {
              $ret .= $typeHint.' ';
              break;
            }

Missing backslash in lib/Wsdl2PhpGenerator/PhpSource/PhpFile.php on line 127

PHP Fatal error: Class 'Wsdl2PhpGenerator\PhpSource\Exception' not found in phar:///home/studiounified/wsdl2phpgenerator-2.2.2.phar/lib/Wsdl2PhpGenerator/PhpSource/PhpFile.php on line 127

It looks like there should be a backslash before Exception, so \Exception. At the moment php is looking for it in the namespace, so \Wsdl2PhpGenerator\PhpSource\Exception instead of \Exception

Refactor SoapClient configuration

The current version of wsdl2phpgenerator has 21 configuration options. 8 of these represent configuration options set to the \SoapClient constructor. The constructor supports many more options and there are occasionally pull requests for adding support for these (e.g. #69 ).

After the changes in #101 land I suggest that we implement a general approach for handling these instead of implementing configuration options individually. We could implement a common prefix and pick up any configuration entries with this prefix, strip the prefix from each entry, combine entries into an array and pass this as the $options array to the \SoapClient constructor.

This would also make it easier to support custom \SoapClient classes as suggested in #93.

Example with prefix soapclient:

$config = new Config();
$config->set('soapclient_login', 'user');
$config->set('soapclient_password', '123');
// Set some more options.
$generator = new Generator();
$generator->generate($config);
// The generated SoapClient subclasses now call `parent::__construct($wsdl, $options);
// where $options['login'] = 'user' and $options['password'] = '123';

vendor/autoload.php

Fatal error: require(): Failed opening required 'vendor/autoload.php'

I get this error when using the executable. Can anyone help?

Add meta infoformation to generated files

When you have a generated file from wsdl2phpgenerator I think it would be useful to be able to see how and perhaps when it was generated. This would make regeneration easier for people who have not automated this proces.

How about adding a file level DocBlock to each generated file with some meta information. An example:

/**
 * This file was was generated by wsdl2phpgenerator 2.3.0 at 11:31 7-3-2013.
 * 
 * Configuration:
 * - input: http://host/service.wsdl
 * - namespace: somenamespace
 * - wsdlCache: CACHE_NODE
 * [..]
 *
 * @package
 */

generating with --createAccessors keeps variable public

When generating with the --createAccessors flag on, all the classes are generated with the set & get accessors. But the variable are kept public while they should be defined as private.

class className{

 /**
 * @var string $MyVar
 * @access public
 */
 public $MyVar;
 //Shouldn't it be "private $MyVar;" ?

 public function getMyVar(){
    return $this->MyVar;
 }

 public function setMyVar($MyVar){
    $this->MyVar =  $MyVar;
 }

}

Nicer and more descriptive errors

The errors should be nicer and more useful. E.g. If you supply a file that
is not an wsdl now you get an exception. This should be a nice error
message.

Overloaded methods

I am having a issue with using methods which are defined using overloads. It seems that these are not supported by this (awesome) library.

My question is: can these methods be called at all using PHP's Soap Client? I have searched on the internet, but have not found a good answer.

Here is an example of what the WSDL looks like (only the relevant parts are included):

<wsdl:definitions>
    <wsdl:types>
        <!-- The input / output from 'SomeMethod' and its overload 'SomeMethodOverload' -->
        <s:schema>
            <s:element name="SomeMethod">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="param1" type="s:string"/>
                        <s:element minOccurs="0" maxOccurs="1" name="param2" type="s:string"/>
                    </s:sequence>
                </s:complexType>
            </s:element>

            <s:element name="SomeMethodResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="1" maxOccurs="1" name="SomeMethodResult" type="s:int"/>
                    </s:sequence>
                </s:complexType>
            </s:element>

            <s:element name="SomeMethodOverload">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="param1" type="s:int"/>
                    </s:sequence>
                </s:complexType>
            </s:element>

            <s:element name="SomeMethodOverloadResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="1" maxOccurs="1" name="SomeMethodOverloadResult" type="s:int"/>
                    </s:sequence>
                </s:complexType>
            </s:element>
        </s:schema>
    </wsdl:types>

    <!-- The messages wrapping the input / output from 'SomeMethod' and its overload 'SomeMethodOverload'-->
    <wsdl:message name="SomeMethodSoapIn">
        <wsdl:part name="parameters" element="tns:SomeMethod"/>
    </wsdl:message>

    <wsdl:message name="SomeMethodSoapOut">
        <wsdl:part name="parameters" element="tns:SomeMethodResponse"/>
    </wsdl:message>

    <wsdl:message name="SomeMethodOverloadSoapIn">
        <wsdl:part name="parameters" element="tns:SomeMethodOverload"/>
    </wsdl:message>

    <wsdl:message name="SomeMethodOverloadSoapOut">
        <wsdl:part name="parameters" element="tns:SomeMethodOverloadResponse"/>
    </wsdl:message>

    <!--
        The operations describing 'SomeMethod' and its overload 'SomeMethodOverload'
        Note: the operations both use the same name, but the overload names the input and output. As I understand it
            Soap does require unique operation names, but the full operation name consists of
            operationName + inputName + outputName, so this is actually valid.
    -->
    <wsdl:portType>
        <wsdl:operation name="SomeMethod">
            <wsdl:documentation>Do something</wsdl:documentation>
            <wsdl:input message="tns:SomeMethodSoapIn"/>
            <wsdl:output message="tns:SomeMethodSoapOut"/>
        </wsdl:operation>

        <wsdl:operation name="SomeMethod">
            <wsdl:documentation>Do something with different parameters</wsdl:documentation>
            <wsdl:input name="SomeMethodOverload" message="tns:SomeMethodOverloadSoapIn"/>
            <wsdl:output name="SomeMethodOverload" message="tns:SomeMethodOverloadSoapOut"/>
        </wsdl:operation>
    </wsdl:portType>
</wsdl:definitions>

Restrictions is not outputted in the phpdoc

Moved from http://code.google.com/p/wsdl2phpgenerator/issues/detail?id=30

What steps will reproduce the problem?

  1. Generate phpfiles from a wsdl which has restrictions on types with ./wsdl2php -i <path/url to wsdl> -o
  2. wsdl may have a type like this:
    <xs:simpleType name="Category">
    <xs:restriction base="xs:string">
    <xs:enumeration value="Sport"/>
    <xs:enumeration value="Culture"/>
    <xs:enumeration value="News"/>
    /xs:restriction
    /xs:simpleType

What is the expected output? What do you see instead?
It would be nice to output the restrictions to the phpdoc. php-wsf's wsdl2php tool does this:
/**
* @var string
* NOTE: Trade should follow the following restrictions
* You can have one of the following value
* Sport
* Culture
* News
*/

As far as I can see wsdl2phpgenerator does not output this:
/**

  • @var Category $Category
  • @access public
    */
    public $Category;

It would be a nice feature :)

What version of the product are you using? On what operating system?
1.4.1-php5.3, Ubuntu 10.06 64 bit.

Please provide any additional information below.
Related Issue: #13 http://code.google.com/p/wsdl2phpgenerator/issues/detail?id=13
This does not work for me (if it's released yet?).

Uppercase the base class.

It appears the name is taken from the filename in the URI. That's fine, but our coding standards dictate that it should be uppercased.

I added $name = ucfirst($name); in src/Service.php.

Replace code generation code with external library

I think we should consider replacing our custom php generation code with an external library.

In line with replacing CLI code with Symfony Console (#) This would allow us to build on a well established code base and focus on the primary task of of the project: The actual conversion of WSDLs to PHP code.

I have considered two libraries:

I am currently leaning towards using ZendCode.

Pros:

Cons:

  • Long dependency chain
  • Small user base

I would love to hear opinions from others.

Non-static method DOMDocument::load() should not be called statically

I ran the following command:

php wsdl2php.php -i c:\wsdl\metaswitch\definition\ShServiceTyped.wsdl -o /files

The following error was produced:

Strict Standards: Non-static method DOMDocument::load() should not be called statically, assuming $this from incompatible context in /wsdl2php/src/Generator.php on line 140

Suggested change:

replace line 140:
$this->dom = DOMDocument::load($wsdl);

with the following:
$this->dom = new DOMDocument;
$this->dom->load($wsdl);

Use Splenum For enums

At the moment, enum classes are generated in PHP this way :

class MyObject{
  const __default = "Default Value";
  const VAL1 = "value1";
  const VAL2 = "value2";
}

This would be "nice to have" a console option called : --withSplEnum

So we can use the class Spl_Enum when having the Spl_Type extension installed
http://www.php.net/manual/en/class.splenum.php

"Nice to have". It sounds like the developer got this in mind while creating this very nice project, when looking at the _default constant.

Tests should not require network connection

The tests fail if the wsdl resource isn't available over the network. We should use local fixture files in our tests, so they will always pass, even if the resource isn't available.

This is not possible with wsdls including imports, not without mocking at least. But a first step could be using fixture files for the files it's possible for.

Contribution guidelines

CONTRIBUTING.md should/could be added to specify things like tabs vs spaces, indentation rules, etc..

Do we have any current standards for this? I know I'm pretty picky when it comes to my own projects.

Out the namespace in the classmap.

The service's $classmap should prefix the classnames with the namespace:

$init .= " '".$type->getIdentifier()."' => '".$config->getNamespaceName()."".$type->getPhpIdentifier()."',".PHP_EOL;

classExists does not include the configured namespace

When creating classes with both the option namespaceName and classExists set, a typical output will look like this:

<?php

namespace My\Namespace;

if (!class_exists("MyClass", false)) 
{
class MyClass
{
    // somewhat somewhat
}
}

The first argument to the function class_exists should include the configured namespace. I think this is the relevant line. Unfortunately I think the namespace will not be available in this class.

I'd consider this issue as low priority. Including the class_exists typically indicates code smell anyway.

separate library and cli tool as different composer packages

I use wsdl2phpgenerator as a library in our project (i.e. dynamically generate/sync php from wsdl). The current wsdl2phpgenerator/wsdl2phpgenerator composer package has dependencies to psr/log and symfony/console, neither of which is needed or wanted when using as library.

I propose we separate the package into two separate ones. The library-only version could be called wsdl2phpgenerator/lib. We could keep the current name for the full package, which itself will require wsdl2phpgenerator/lib.

I think this will not break BC as far as composer is concerned. However I think we would need to create a github repo called lib here and move the main library into it, which could mess up people's forks. Not being too familiar with composer, I'm not sure if there is a better way to handle this without a new repo.

Missing support for relative import paths

With https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl as the WSDL, we have this warnings :

  • Warning: simplexml_load_file(): I/O warning : failed to load external entity "CoreComponentTypes.xsd" in /var/www/mikael/wsdl2phpgenerator-master/src/Generator.php on line 208
  • Warning: simplexml_load_file(): I/O warning : failed to load external entity "eBLBaseComponents.xsd" in /var/www/mikael/wsdl2phpgenerator-master/src/Generator.php on line 208
  • Warning: simplexml_load_file(): I/O warning : failed to load external entity "EnhancedDataTypes.xsd" in /var/www/mikael/wsdl2phpgenerator-master/src/Generator.php on line 208

Use WSDL documentation in phpdoc comment block

Use the WSDL documentation, if there is one, to document the soap client methods and class itself.

Example:

<wsdl:portType name="Contact">
      <wsdl:documentation>
         <summary>Declaration of Wcf web services for Contact</summary>
      </wsdl:documentation>
      <wsdl:operation name="CreateDefaultContactEntity">
         <wsdl:documentation>
            <summary>Loading default values into a new ContactEntity.  NetServer calculates default values (e.g. Country) on the entity, which is required when creating/storing a new instance.</summary>
         </wsdl:documentation>
         <wsdl:input wsaw:Action="http://www.superoffice.net/ws/crm/NetServer/7.0.2000.2000/Contact/CreateDefaultContactEntity" name="CreateDefaultContactEntityRequest" message="tns:CreateDefaultContactEntityRequest"/>
         <wsdl:output wsaw:Action="http://www.superoffice.net/ws/crm/NetServer/7.0.2000.2000/Contact/CreateDefaultContactEntityResponse" name="CreateDefaultContactEntityResponse" message="tns:CreateDefaultContactEntityResponse"/>
      </wsdl:operation>

Separate schema parsing

One of the WSDL services I use is a bit unorthodox in the sense where they return <xs:schema> elements as a piece of their responses when you call methods.

When generated with wsdl2phpgenerator, the field is simply a string that accepts XML data. This XML structure is defined by the schema they return as part of the response (as mentioned above).

I'm looking for a way to go from these schema elements to generated classes. I am digging through the wsdl2phpgenerator code to see how this is done; perhaps with some guidance I could submit a pull-request with changes that make this easier for others too.

Configuration backwards compatibility

In the description of the versioning strategy for the project we state that we use semantic versioning and that \Wsdl2PhpGenerator\ConfigInterface constitutes part of our public interface.

This situation makes it challenging to deal with adding new configuration options and preserving backwards compatibility.

Currently adding a new configuration option means adding a getter method to the ConfigInterface and implementing the method in the Config class.

However adding the method to the interface also means that any 3. party code implementing the interface will break after updating as their implementation does not comply with the specification of the interface.

Thus we do not preserve backwards compatibility and according to semantic versioning standards we should bump our major version, which seems silly for what is usually a minor new feature.

We have an increasing number of contributions (e.g. #69 #93 #81) which add configuration options so the situation needs to be dealt with to have a good solution for a release 3.x.

I see the following options:

  1. Remove \Wsdl2PhpGenerator\ConfigInterface from what constitutes the public interface. The use cases for providing 3. party implementations are not obvious anyway
  2. Use a different model for accessing configuration parameters e.g. $config->get('some-option')
  3. Switch from a interface to an abstract class for configuration. New configuration options and default accessors can be added here and overridden in implementations.

I would appreciate peoples opinion on these options. Other suggestions are also very welcome.

Make datatype class constructor only take required SOAP variables

I think making the datatype class constructors only take required SOAP variables (eg. not nillable) would make them more usable and readable. For example let say you have a complex type like:

<xs:complexType name="ContactEntity">
      <xs:complexContent mixed="false">
         <xs:extension base="tns:Carrier">
            <xs:sequence>
               <xs:element minOccurs="0" name="ActiveInterests" type="xs:int"/>
               <xs:element minOccurs="0" name="ActiveStatusMonitorId" type="xs:int"/>
               <xs:element minOccurs="0" name="Address" nillable="true" type="tns:Address"/>
               <xs:element minOccurs="0" name="Associate" nillable="true" type="tns:Associate"/>
               <xs:element minOccurs="0" name="Business" nillable="true" type="tns:Business"/>
               <xs:element minOccurs="0" name="Category" nillable="true" type="tns:Category"/>
               <xs:element minOccurs="0" name="ContactId" type="xs:int"/>
               <xs:element minOccurs="0" name="Country" nillable="true" type="tns:Country"/>
               <xs:element minOccurs="0" name="CreatedBy" nillable="true" type="tns:Associate"/>
               <xs:element minOccurs="0" name="CreatedDate" type="xs:dateTime"/>
               <xs:element minOccurs="0" name="CustomerLanguage" nillable="true" type="tns:CustomerLanguage"/>
               <xs:element minOccurs="0" name="DbiAgentId" type="xs:int"/>
               <xs:element minOccurs="0" name="DbiKey" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="DbiLastModified" type="xs:dateTime"/>
               <xs:element minOccurs="0" name="DbiLastSyncronized" type="xs:dateTime"/>
               <xs:element minOccurs="0" name="Deleted" type="xs:short"/>
               <xs:element minOccurs="0" name="Department" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="Description" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="Emails" nillable="true" type="q1:ArrayOfEntityElement" xmlns:q1="http://schemas.datacontract.org/2004/07/SuperOffice.CRM.Services"/>
               <xs:element minOccurs="0" name="ExtraFields" nillable="true" type="tns:StringDictionary"/>
               <xs:element minOccurs="0" name="Faxes" nillable="true" type="q2:ArrayOfEntityElement" xmlns:q2="http://schemas.datacontract.org/2004/07/SuperOffice.CRM.Services"/>
               <xs:element minOccurs="0" name="GroupId" type="xs:int"/>
               <xs:element minOccurs="0" name="Interests" nillable="true" type="tns:ArrayOfSelectableMDOListItem"/>
               <xs:element minOccurs="0" name="Kananame" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="NoMailing" type="xs:boolean"/>
               <xs:element minOccurs="0" name="Number1" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="Number2" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="OrgNr" nillable="true" type="xs:string"/>
               <xs:element minOccurs="0" name="Persons" nillable="true" type="tns:ArrayOfPerson"/>
               <xs:element minOccurs="0" name="Phones" nillable="true" type="q3:ArrayOfEntityElement" xmlns:q3="http://schemas.datacontract.org/2004/07/SuperOffice.CRM.Services"/>
               <xs:element minOccurs="0" name="Source" type="xs:short"/>
               <xs:element minOccurs="0" name="SupportAssociate" nillable="true" type="tns:Associate"/>
               <xs:element minOccurs="0" name="SupportPerson" nillable="true" type="tns:Person"/>
               <xs:element minOccurs="0" name="TicketPriority" nillable="true" type="tns:TicketPriority"/>
               <xs:element minOccurs="0" name="UpdatedBy" nillable="true" type="tns:Associate"/>
               <xs:element minOccurs="0" name="UpdatedDate" type="xs:dateTime"/>
               <xs:element minOccurs="0" name="Urls" nillable="true" type="q4:ArrayOfEntityElement" xmlns:q4="http://schemas.datacontract.org/2004/07/SuperOffice.CRM.Services"/>
               <xs:element minOccurs="0" name="UserDefinedFields" nillable="true" type="tns:StringDictionary"/>
               <xs:element minOccurs="0" name="Xstop" type="xs:boolean"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

Creating that object and specifying all parameters would make it very unreadable. However if the constructor was just:

<?php
function __constructor($ActiveInterests, $ActiveStatusMonitorId, 
$ContactId, $CreatedDate, $DbiAgentId, $DbiLastModified, 
$DbiLastSyncronized, $Deleted, $GroupId, $NoMailing, 
$Source, $UpdatedDate, $Xstop) {
}

I'd at least have a chance to make some sense out of it.

Arguments as arrays

@chriskl writes in #38:

At some point I rebuilt the classes for my phpssrs project using
wsdl2phpgenerator and I'm now getting methods like this:

+  /**
+   *
+   * @param InheritParentSecurity $parameters
+   * @access public
+   * @return InheritParentSecurityResponse
+   */
+  public function InheritParentSecurity(InheritParentSecurity $parameters)
+  {
+    return $this->__soapCall('InheritParentSecurity', array($parameters));
+  }

I think it's because I changed the xsi arrays options. Note though that
the method definition is completely bogus, right? It will end up doing a
soapcall with an array with a single element that is an
InheritParentSecurity object in it. Shouldn't it be (array)$parameters?

To be honest, neither version seems to work for me at the moment (soapCall
complains that no parameters are being passed), but still trying to figure
out the issue.

"A constant of the name xxx does already exist" by Enumeration

The wsdl has enumeration, for example

<s:restriction base="s.string">
  <s:enumeration value="BigInt" />
  <s:enumeration value="Binary" />
  <s:enumeration value="Bit" />
  <s:enumeration value="Char" />
  <s:enumeration value="DateTime" />
  <s:enumeration value="Decimal" />
  <s:enumeration value="Float" />

In the case, Wsdl2PhpGenerator\Enum#generateClass() $this->values is array (['BigInt','Binary',.....]).

If $value Decimal, $name become to float by Wsdl2PhpGenerator\Enum L56 or L61.
Also, $value is Float, $name become to float by the line.

$this->class->addConstat($value,$name) throw Exception because $name `float' is duplicated.

Why convert $name from $value?

Remove obsolete configuration options

wsdl2phpgenerator has numberous configuration options. The project was started >3 years ago and I think some of the options reflect old PHP development problems. PHP development practices have evovled and the project requires PHP 5.3. I think it would be good to remove some of these configuration options as well to make the clone cleaner.

My suggestions are:

  • classExists: If all classes should be guarded with if(!class_exists) statements. This configuration seems to be from a time without autoloaders and uncontrolable includes. Besides it does not work with namespaces (see #96). It should no longer be necessary in 2014.
  • createAccessors: Create getter and setter methods for member variables. In my opinion accessor creation should be default behavior. Properties should be declared protected as addressed in #88.
  • constructorNull: Makes all constructor arguments default to null. If a argument is not nillable I think it should be required to set it in the constructor. Thus this configuration should no longer be used.
  • noIncludes: Do not add include_once statements for loading individual files. We have all sorts of different autoloaders now. Generating includes should no longer be necessary. If someone thinks so I suggest that they implement autoloader generation as a separate option afterwards.
  • prefix/suffix: The prefix to use for the generated classes. We have namespaces now. This configuration option should no longer be necessary.
  • singleFile: If the output should be a single file. See prefix/suffix.

My suggestions are partly based on the fact that I have not found these options useful in my work. I would love to hear from someone who has.

Methods that return a single result are returned as ResultType object instead of ResultArrayType

We have an API that returns email recipients via the getRecipients() SOAP method.

The method returns the following field:

recipients - unbounded;  type RecipientType
This datatype represents a recipient.

If there is more than one recipient, we get back a RecipientArrayType. (Expected)
However, if there is only one Recipient, we get back an RecipientType. (Not expected.)

Example:

Many recipients:

$recipients = $api->getRecipients();
echo gettype($recipients->recipient); //RecipientArrayType

One recipient:

$recipients = $api->getRecipients();
echo gettype($recipients->recipient); //RecipientType

The issue is that we now have to each time check the object type and perform two separate loops. I would want the getRecipients() method to always return a RecipientArray, independent on how many results there are.

I'm not completely sure if this is an issue with this project or the SOAP API we are using, hopefully someone can point me in the right direction.

Constants with names resolving to PHP primitives are created incorrectly

Something weird is happening in PhpClass::addConstant( $value, $name ): whenever a constant is added with a name that resolves to a PHP primitive (e.g. DECIMAL --> float, INTEGER --> int, LONG --> int), the name of the primitive is added as a constant instead of the name itself.

This is a problem in situations, for example, where we have a WSDL describing an enumeration with constants like the following:

<xs:enumeration value="INTEGER"/>
<xs:enumeration value="LONG"/>

In this case, an exception is thrown because INTEGER and LONG both resolve to int.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.