Expected "non-empty-string", got "string"
i've faced with trouble on generate:classmap/types it return me an exeption with Expected "non-empty-string", got "string". How to fix that?
Originally posted by @blessq12 in https://github.com/phpro/soap-client/issues/504#issuecomment-2029513373
i have the same issue.
trying to use the following WSDL,
https://tst.itserve.ch/swissdec/refapps/next/receiver/services/SalaryDeclarationService20200220?wsdl
trying to run the wizard gives me the error above mentioned
i have the same issue.
trying to use the following WSDL,
https://tst.itserve.ch/swissdec/refapps/next/receiver/services/SalaryDeclarationService20200220?wsdltrying to run the wizard gives me the error above mentioned
im disabled to type 'non-empty-string' check and wizard all done
in file NonEmptyStringType.php comment all thing that inner assert method and just return value from method. this will disable check type and wizard can go forward
Disabling the non-empty-string sounds like a very bad idea to be honest.
Feel free to provide more information, like WSDL. Configs,... so that it can be investigated further. It might be all separate issues as well.
One known issue that results in a non-empty-string situation is this one: https://github.com/php-soap/wsdl-reader/issues/23#issuecomment-2028484925
A PR that fixes that specific issue is linked and can be tested on your project as well. It might be the same.
I'm a bit busy the next days so I might not be able to provide a fast solution ATM.
but in the other way if dont disable checking a non-empty-string i've give a exception and thats all. wizard stops with exception and not be able to generate separately types or classmap
One known issue that results in a non-empty-string situation is this one: php-soap/wsdl-reader#23 (comment)
Unfortuantly that does not work either.
im using the following config
<?php
use Phpro\SoapClient\CodeGenerator\Assembler;
use Phpro\SoapClient\CodeGenerator\Rules;
use Phpro\SoapClient\CodeGenerator\Config\Config;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory;
return Config::create()
->setEngine($engine = CodeGeneratorEngineFactory::create(
'https://tst.itserve.ch/swissdec/refapps/next/receiver/services/SalaryDeclarationService20200220?wsdl'
))
->setTypeDestination('src/Type')
->setTypeNamespace('App\Type')
->setClientDestination('src\client')
->setClientName('SwissdecClient')
->setClientNamespace('App\Client')
->setClassMapDestination('src\classmap')
->setClassMapName('SwissdecClassmap')
->setClassMapNamespace('App\Classmap')
->addRule(new Rules\AssembleRule(new Assembler\GetterAssembler(
(new Assembler\GetterAssemblerOptions())->withDocBlocks(true)
)))
->addRule(new Rules\AssembleRule(new Assembler\ImmutableSetterAssembler(
(new Assembler\ImmutableSetterAssemblerOptions())->withDocBlocks(true)
)))
->addRule(
new Rules\IsRequestRule(
$engine->getMetadata(),
new Rules\MultiRule([
new Rules\AssembleRule(new Assembler\RequestAssembler()),
new Rules\AssembleRule(new Assembler\ConstructorAssembler(
(new Assembler\ConstructorAssemblerOptions())->withDocBlocks(true)
)),
])
)
)
->addRule(
new Rules\IsResultRule(
$engine->getMetadata(),
new Rules\MultiRule([
new Rules\AssembleRule(new Assembler\ResultAssembler()),
])
)
)
->addRule(
new Rules\IsExtendingTypeRule(
$engine->getMetadata(),
new Rules\AssembleRule(new Assembler\ExtendingTypeAssembler())
)
)
->addRule(
new Rules\IsAbstractTypeRule(
$engine->getMetadata(),
new Rules\AssembleRule(new Assembler\AbstractClassAssembler())
)
)
;
This is on an entierly new Project. (composer.json)
{
"require": {
"php-soap/psr18-wsse-middleware": "^2.3",
"symfony/http-client": "^6.4",
"nyholm/psr7": "^1.8",
"phpro/soap-client": "^3.1"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
@jfschubert
https://tst.itserve.ch/swissdec/refapps/next/receiver/services/SalaryDeclarationService20200220?wsdl
The problem in this WSDL is:
<xs:simpleType name="EmptySimpleType">
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
Whilst, our meta class says:
/**
* @throws CoercionException
*/
public function withEnums(?array $enums): self
{
$new = clone $this;
$new->enums = optional(vec(non_empty_string()))->coerce($enums);
return $new;
}
So the fix lies in reworking php-soap/engine/src/Metadata/Model/TypeMeta.php to allow simple strings() instead of non-empty-strings. When doing the change, we need to make sure that enumeration code-generation doesn't fail.
@blessq12 you got any wsdl to share so that I can see what is going wrong there as well?
@veewee sure ive got one and so much troubles how to use it normal
http://smev3-n0.test.gosuslugi.ru:7500/smev/v1.1/ws?wsdl
when i disable check type ( when i get an exception with non-empty-string ) the wizard generate all file that i need to create
a request to smev system but not it's return an SOAP-ERROR: Encoding: object has no 'any' property
and just one another question, can your lib to sign an part of envelope? i need to create an envelope and sign one part of it
@veewee Thank you for looking into it. Its only used in ONE of the possible Type got that while doing a return $value."FIXMEWSDL" instead of throw. and got exactly ONE Result afterwards. so i fixed the type by hand.
@blessq12, I've investigated the WSDL and it's the same issue I linked above. https://github.com/php-soap/wsdl-reader/pull/24 (I've tagged this one, so an update should be available through composer)
When I apply that patch, It is able to generate the types. It might or might not be the reason why you get the soap-error : the provided classes are not valid at that moment.
However I do see one additional issue:
Error generating Type\SenderProvidedRequestData:Type "void" cannot be nullable
This is due to:
\Phpro\SoapClient\CodeGenerator\Util\Normalizer::$normalizations contains void => void, but the XML contains a Voidtype:
Void
====
> urn://x-artefacts-smev-gov-ru/services/message-exchange/types/basic/1.1:Void
+------------+------------------------------------------------------------------+
| Meta | Value |
+------------+------------------------------------------------------------------+
| isAbstract | false |
| docs | Тип элемента, который передаёт информацию фактом своего наличия. |
+------------+------------------------------------------------------------------+
For signing parts of the envelope, you can use: https://github.com/php-soap/psr18-wsse-middleware
@jfschubert , @blessq12
I made PRs in the various sections where things went wrong.
- https://github.com/php-soap/wsdl-reader/releases/tag/0.10.0
- https://github.com/php-soap/engine/releases/tag/2.7.0
- https://github.com/phpro/soap-client/releases/tag/3.1.2
You should be able to generate the types now given the WSDL you provided me.
If you like the work we provide here: feel free to sponsor us.