Closed tgerakitis closed 3 years ago
The error can't be avoided, please send me the wsdl at contact@mikael-delsol.fr, thx
hi @mikaelcom thank you very much. I've sent you the email, pls check your spam folder just in case. best, theo
hi @mikaelcom pls let me know in case I can help! best theo
It should be fixed.
Can you try using docker image from https://hub.docker.com/repository/docker/mikaelcom/wsdltophp? Or from phar file from https://github.com/WsdlToPhp/PackageGenerator/releases/tag/feature%2Fissue-227
hey @mikaelcom, thank you, import works perfectly now.
I have a few different problems now with PHP stating:
{
"name": "PHP Compile Error",
"message": "Default value for parameters with a class type can only be NULL",
"code": 64,
"type": "yii\\base\\ErrorException",
"file": "/app/components/pkg/premium/StructType/Payload.php",
...
The reason is that the generated code looks like this: (this is one simple example - this error is in __construct
as well.
public function setHistory(\app\components\pkg\premium\StructType\History $history = 'no')
{
$this->history = $history;
return $this;
}
where the 'no'
is supposed to be null
.
I fixed it manually to see if it would work, there is still a problem with the request body because it adds a wrapping <parameter>
which should be an <xxxLogin>
element instead.
How it is supposed to look like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<xxxLogin>
<request>
<payload>
....
how it looks:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<parameter>
<request>
<method />
<payload>
I copied the generated body over to SoapUI and changed the parameter
element to xxxLogin
and it worked fine.
My code:
$pkg = new pkg([
AbstractSoapClientBase::WSDL_ENCODING => 'UTF-8',
AbstractSoapClientBase::WSDL_USER_AGENT => 'CompanypkgSoap/1.0.0',
AbstractSoapClientBase::WSDL_URL =>
'https://www.mypkg.com/?wsdl',
AbstractSoapClientBase::WSDL_URI =>'https://www.mypkg.com/',
AbstractSoapClientBase::WSDL_CLASSMAP =>
\app\components\pkg\premium\ClassMap::get(),
AbstractSoapClientBase::WSDL_SOAP_VERSION => SOAP_1_1
]);
$payload = new Payload();
$payload->personId = $personId;
$payload->clearingId = $clearingId;
$payload->password = $password;
$loginRequest = new Request();
$loginRequest->payload = $payload;
$response = $pkg->pkgLogin(new pkgLogin($loginRequest));
hey @mikaelcom, thank you, import works perfectly now.
I have a few different problems now with PHP stating:
{ "name": "PHP Compile Error", "message": "Default value for parameters with a class type can only be NULL", "code": 64, "type": "yii\\base\\ErrorException", "file": "/app/components/pkg/premium/StructType/Payload.php", ...
The reason is that the generated code looks like this: (this is one simple example - this error is in
__construct
as well.public function setHistory(\app\components\pkg\premium\StructType\History $history = 'no') { $this->history = $history; return $this; }
where the
'no'
is supposed to benull
.
I'm going to fix it too indeed!
I fixed it manually to see if it would work, there is still a problem with the request body because it adds a wrapping
<parameter>
which should be an<xxxLogin>
element instead.How it is supposed to look like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <xxxLogin> <request> <payload> ....
how it looks:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Header /> <SOAP-ENV:Body> <parameter> <request> <method /> <payload>
I copied the generated body over to SoapUI and changed the
parameter
element toxxxLogin
and it worked fine.My code:
$pkg = new pkg([ AbstractSoapClientBase::WSDL_ENCODING => 'UTF-8', AbstractSoapClientBase::WSDL_USER_AGENT => 'CompanypkgSoap/1.0.0', AbstractSoapClientBase::WSDL_URL => 'https://www.mypkg.com/?wsdl', AbstractSoapClientBase::WSDL_URI =>'https://www.mypkg.com/', AbstractSoapClientBase::WSDL_CLASSMAP => \app\components\pkg\premium\ClassMap::get(), AbstractSoapClientBase::WSDL_SOAP_VERSION => SOAP_1_1 ]); $payload = new Payload(); $payload->personId = $personId; $payload->clearingId = $clearingId; $payload->password = $password; $loginRequest = new Request(); $loginRequest->payload = $payload; $response = $pkg->pkgLogin(new pkgLogin($loginRequest));
This issue is not due to the generator nor the generated package but due to the native SoapClient class that uses the WSDL to generate the XML request.
In your case, the xxxLogin element is defined in the WSDL such as:
<wsdl:message name="xxxLoginRequest">
<wsdl:part name="parameter" element="xxxLogin"/>
</wsdl:message>
This is why SoapClient names the xxxLogin to parameter.
Renaming dynamically the parameter to the real parameter name is feasible by overriding the SoapClient in order to rewrite the XML request before it is actually sent.
The default value is now fixed!
@mikaelcom defaults look good, thank you
I'm getting this error now when trying to set my first request:
PHP Fatal error: Uncaught Error: Call to a member function __soapCall(
When running this code (no changes to other code parts, just wsdl to PHP generation and then running the same code):
$pkg = new pkg([
AbstractSoapClientBase::WSDL_ENCODING => 'UTF-8',
AbstractSoapClientBase::WSDL_USER_AGENT => 'CompanypkgSoap/1.0.0',
AbstractSoapClientBase::WSDL_URL =>
'https://www.mypkg.com/?wsdl',
AbstractSoapClientBase::WSDL_URI =>'https://www.mypkg.com/',
AbstractSoapClientBase::WSDL_CLASSMAP =>
\app\components\pkg\premium\ClassMap::get(),
AbstractSoapClientBase::WSDL_SOAP_VERSION => SOAP_1_1
]);
$payload = new Payload();
$payload->personId = $personId;
$payload->clearingId = $clearingId;
$payload->password = $password;
$loginRequest = new Request();
$loginRequest->payload = $payload;
$response = $pkg->pkgLogin(new pkgLogin($loginRequest));
About the SoapClient
Renaming dynamically the parameter to the real parameter name is feasible by overriding the SoapClient in order to rewrite the XML request before it is actually sent.
Can I simply use the class you've linked to or do I actually need to write my own wrapper?
@mikaelcom defaults look good, thank you I'm getting this error now when trying to set my first request:
PHP Fatal error: Uncaught Error: Call to a member function __soapCall(
When running this code (no changes to other code parts, just wsdl to PHP generation and then running the same code):
$pkg = new pkg([ AbstractSoapClientBase::WSDL_ENCODING => 'UTF-8', AbstractSoapClientBase::WSDL_USER_AGENT => 'CompanypkgSoap/1.0.0', AbstractSoapClientBase::WSDL_URL => 'https://www.mypkg.com/?wsdl', AbstractSoapClientBase::WSDL_URI =>'https://www.mypkg.com/', AbstractSoapClientBase::WSDL_CLASSMAP => \app\components\pkg\premium\ClassMap::get(), AbstractSoapClientBase::WSDL_SOAP_VERSION => SOAP_1_1 ]); $payload = new Payload(); $payload->personId = $personId; $payload->clearingId = $clearingId; $payload->password = $password; $loginRequest = new Request(); $loginRequest->payload = $payload; $response = $pkg->pkgLogin(new pkgLogin($loginRequest));
Please send me the real values by email, I don't see any error regarding the generated package
About the SoapClient
Renaming dynamically the parameter to the real parameter name is feasible by overriding the SoapClient in order to rewrite the XML request before it is actually sent.
Can I simply use the class you've linked to or do I actually need to write my own wrapper?
You have to write your own, tricky in your case I must admit.
Hi @mikaelcom,
again about the fatal error: It does not seem to have anything to do with the values that I use. I get the same error with empty string values.
I guess the problem lies somewhere in the generation - I may be doing something wrong here:
This is the docker-compose.yml
that I used to generate my package
wsdltophp:
image: mikaelcom/wsdltophp:feature-issue-227
volumes:
- "./app/:/app/"
command: >
generate:package
--urlorpath="https://www.mypkg.com/?wsdl"
--namespace="app\components\pkg\premium"
--destination="/app/components/pkg/premium"
--src-dirname=""
--gentutorial
--standalone=false
--force
I'm using the framework yii2
which autoloads according to PSR and finds the namespaced class without any problem.
The error gets thrown here:
/**
* This class stands for Pkg ServiceType
* @subpackage Services
*/
class Pkg extends AbstractSoapClientBase
{
/**
* Method to call the operation originally named PkgLogin
* Meta information extracted from the WSDL
* - documentation: Login | Login
* @uses AbstractSoapClientBase::getSoapClient()
* @uses AbstractSoapClientBase::setResult()
* @uses AbstractSoapClientBase::getResult()
* @uses AbstractSoapClientBase::saveLastError()
* @param \app\components\Pkg\premium\StructType\PkgLogin $PkgLogin
* @return \app\components\Pkg\premium\StructType\PkgLoginResponse|bool
*/
public function PkgLogin(\app\components\Pkg\premium\StructType\PkgLogin $PkgLogin)
{
try {
// this line below causes Exception: Error: Call to a member function __soapCall() on null
$this->setResult($this->getSoapClient()->__soapCall('PkgLogin', array(
$PkgLogin,
), array(), array(), $this->outputHeaders));
return $this->getResult();
} catch (\SoapFault $soapFault) {
$this->saveLastError(__METHOD__, $soapFault);
return false;
}
}
Then I think you wrongly instantiate and use the service class.
Can you show how you instantiate and use this service class?
Hi @mikaelcom ,
this is my code:
$pkg = new Pkg([
AbstractSoapClientBase::WSDL_ENCODING => 'UTF-8',
AbstractSoapClientBase::WSDL_USER_AGENT => 'CompanypkgSoap/1.0.0',
AbstractSoapClientBase::WSDL_URL =>
'https://www.mypkg.com/?wsdl',
AbstractSoapClientBase::WSDL_URI =>'https://www.mypkg.com/',
AbstractSoapClientBase::WSDL_CLASSMAP =>
\app\components\pkg\premium\ClassMap::get(),
AbstractSoapClientBase::WSDL_SOAP_VERSION => SOAP_1_1
]);
$payload = new Payload();
$payload->personId = $personId;
$payload->clearingId = $clearingId;
$payload->password = $password;
$loginRequest = new Request();
$loginRequest->payload = $payload;
$response = $pkg->pkgLogin(new pkgLogin($loginRequest));
This is details but why do you specify these parameters:
Is it necessary?
Anyway, even with these parameters, I succeed to call the WS, I'll email my script, you'll tell me :wink:
hi @mikaelcom thanks for your help, it seems it was a configuration issue on my side. Best, Theo
Hi, when trying to import a WSDL (can provide example only directly and not here) I get the error below upon running the following code:
Am I doing something wrong? Is there a way to catch this error and to continue generating the stubs? The error is not giving me any information on what part of the WSDL is causing the issue. It might simply be a part of a service that I don't need anyways.