Skip to content
Mikaël DELSOL edited this page Sep 24, 2015 · 20 revisions

Basic Authentication

How do I generate a package using a WSDL protected by a Basic Authentication?
$ wget https://phar.wsdltophp.com/wsdltophp.phar
$ ./wsdltophp.phar generate:package \
    --urlorpath="http://www.mydomain.com/wsdl.xml" \
    --destination="/path/to/where/the/package/must/be/generated/" \
    --prefix="MyPackage" \
    ###############################################
    # Here are the Basic Authentication credentials
    --login="basic_auth_login" \
    --password="basic_auth_password" \
    ###############################################
    --force
How do I call a SOAP Web Service using a WSDL protected by a Basic Authentication?
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
$options = array(
    AbstractSoapClientBase::WSDL_URL => 'http://www.mydomain.com/wsdl.xml',
    AbstractSoapClientBase::WSDL_CLASSMAP => \MyPackage\MyPackageClassMap::get(),
    ###############################################
    # Here are the Basic Authentication credentials
    AbstractSoapClientBase::WSDL_LOGIN => 'basic_auth_login',
    AbstractSoapClientBase::WSDL_LOGIN => 'basic_auth_password',
    ###############################################
);

PHP reserved keywords

How to avoid having fatal error with the operations?

If your Web Service provides a method named list, which is a PHP reseverd keywords, you don't have anything to do. Indeed, the generator takes care of generating a method with a unique name. You can view how it works here in the source code.

How to avoid having fatal error with the structs?

In case your Web Service provides structs named like PHP reserved keywords, the generator does not automatically rename the generated class as it can be hazardous.

To avoid having Structs named like PHP reserved keywords, you have two options which can be used independently or simultaneously:

  • prefix: this option prepends any generated Structs', and operations', name with the string you define. A Struct named List with prefix=Ws will be named WsList. You use the WsList classs and it will be send as List Struct thanks to the classmap SoapClient's option.
  • suffix: this option appends any generated Structs', and operations', name with the string you define. A Struct named List with suffix=Ws will be named ListWs. You use the ListWs classs and it will be send as List Struct thanks to the classmap SoapClient's option.

Namespacing

How do I use my own namespace?

If you need to namespace the generated classes, you can use the namespace option such as namespace='My\Own\Namespace'

Proxy

How do I generate a package using a WSDL while I'm behind a proxy?

If you're behind a prox and you can't access the WSDL, then you can use the proxy's options:

$ wget https://phar.wsdltophp.com/wsdltophp.phar
$ ./wsdltophp.phar generate:package \
    --urlorpath="http://www.mydomain.com/wsdl.xml" \
    --destination="/path/to/where/the/package/must/be/generated/" \
    --prefix="MyPackage" \
    #############################
    # Here are the proxy settings
    --proxy-host="my.proxy.cache.proxy" \
    --proxy-port=7552 \
    --proxy-login="my_proxy_login" \
    --proxy-password="my_proxy_password" \
    #############################
    --force
How do I call a SOAP Web Service using a WSDL while I'm behind a proxy?
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
$options = array(
    AbstractSoapClientBase::WSDL_URL => 'http://www.mydomain.com/wsdl.xml',
    AbstractSoapClientBase::WSDL_CLASSMAP => \MyPackage\MyPackageClassMap::get(),
    #############################
    # Here are the proxy settings
    AbstractSoapClientBase::WSDL_PROXY_HOST => 'my.proxy.cache.proxy',
    AbstractSoapClientBase::WSDL_PROXY_PORT => 7552,
    AbstractSoapClientBase::WSDL_PROXY_LOGIN=> 'my_proxy_login',
    AbstractSoapClientBase::WSDL_PROXY_PASSWORD => 'my_proxy_password',
    #############################
);

SoapClient

Can I use my own SoapClient class when generating the package?

No. Normally all the necessary options are provided by the generator to be able to reach the WSDL and its schemas. If not, please let us by [creating an issue](https://github.com/WsdlToPhp/PackageGenerator/issues/new?title=I want to use my own SoapClient when generating the package).

Can I use my own SoapClient class when sending requests with the generated package?

Yes. The generated package uses the decorator pattern in order to be able to provide additional utility methods on top of the SoapClient class. To learn more about the utility methods, please read the PackageBase README file. The PackageBase project contains all the base classes from which Structs (simple and array) and Operations classes inherit.

By default, the generated Operations classes inherit from the WsdlToPhp\PackageBase\AbstractSoapClientBase class. The name of the used class is an option that can be modified when you generate the package. The option soapclient gives you the availability to use your own SoapClient class representation. The only constraint, in order to make it work well, is that you must create at least one class. A class that:

To learn more how to do it, once again please read the PackageBase README file.

Clone this wiki locally