-
Notifications
You must be signed in to change notification settings - Fork 74
$ 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
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',
###############################################
);
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.
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
withprefix=Ws
will be namedWsList
. You use theWsList
classs and it will be send asList
Struct thanks to theclassmap
SoapClient's option. -
suffix: this option appends any generated Structs', and operations', name with the string you define. A Struct named
List
withsuffix=Ws
will be namedListWs
. You use theListWs
classs and it will be send asList
Struct thanks to theclassmap
SoapClient's option.
If you need to namespace the generated classes, you can use the namespace
option such as namespace='My\Own\Namespace'
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
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',
#############################
);
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).
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:
- implements the SoapClientInterface interface OR
- inherits from the AbstractSoapClientBase. So you only have to define your own getSoapClientClassName method.
To learn more how to do it, once again please read the PackageBase README file.