Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 2.08 KB

generate-types.md

File metadata and controls

68 lines (50 loc) · 2.08 KB

Generating Value-objects

Basic value-objects can be generated automatically.

$ ./vendor/bin/soap-client generate:types
                                                                                                                                       [16:13:38]
Usage:
  generate:types [options]

Options:
      --config=CONFIG   The location of the soap code-generator config file

This generator will read all XSD types from the provided WSDL and convert it to PHP classes. You can specify a namespace and a location where the classes will be stored. The properties from the XSD will be added as protected properties to the value-objects. When the classes already exist, a patch operation is performed and a backup file is created. This way your custom code will always remain available.

Keep in mind that the WSDL must provide all XSD types for the generation of value-objects. Some exotic SOAP services don't provide much information. For example: they will return an XML string which needs to be parsed manually. These WSDLs can only be parsed as far as the XSD information goes. All other information needs to be added manually, or by a custom class generator.

Options:

When the value objects are generated, you will still need to customize them. For example by adding the required interfaces:

class HelloWorldRequest implements RequestInterface
{
    public function __construct($name) {
        $this->name = $name
    }

    // Generated code
}

class HelloWorldResponse implements ResponseProviderInterface
{
    // Generated code
    
    public function getResponse()
    {
        return $this->greeting;
    }
}

class Greeting implements ResponseInterface
{
    // Generated code
    
    public function getGreeting()
    {
        return $this->greeting;
    }
}

This can be done by specifying some code generation rules and assemblers.

Next: Generate a class map