Skip to content
Mikaël DELSOL edited this page Sep 10, 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
Clone this wiki locally