-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsignedInt type not supported #504
Comments
Thanks for reporting, Can you swap: ->setEngine($engine = DefaultEngineFactory::create($options)) With ->setEngine($engine = CodeGeneratorEngineFactory::create(
$options->getWsdl(),
// Optional if you wanna load a local file instead of over HTTP : new FlatteningLoader(new StreamWrapperLoader())
)) As documented in the v3 changelog : https://github.com/phpro/soap-client/blob/v3.x/UPGRADING.md#v2-to-v3 For me, this generates: /**
* @var int
*/
private int $relayMask;
/**
* @return int
*/
public function getRelayMask() : int
{
return $this->relayMask;
}
/**
* @param int $relayMask
* @return static
*/
public function withRelayMask(int $relayMask) : static
{
$new = clone $this;
$new->relayMask = $relayMask;
return $new;
} (I've just used a configuration from an old project to quickly test, so the generated methods might be different from what you configured) |
@veewee Definitelly i can try, but the WSDL document (in my particular case) is behind basic auth. Can you help me how to pass the authentication ? |
Something like this: use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Client\Common\PluginClient;
use Http\Discovery\Psr18ClientDiscovery;
use Http\Message\Authentication\BasicAuth;
use Soap\Psr18Transport\Wsdl\Psr18Loader;
use Soap\Wsdl\Loader\FlatteningLoader;
->setEngine($engine = CodeGeneratorEngineFactory::create(
'http://yourremotewsdl',
new FlatteningLoader(Psr18Loader::createForClient(
new PluginClient(
Psr18ClientDiscovery::find(),
[
new AuthenticationPlugin(
new BasicAuth('username', 'password')
)
]
)
))
)) |
Great. It works perfectly. There's just one last issue, which I believe you will solve far more sooner than me. I am posting the whole unchanged WSDL in attachment. The last thing is, it generates class TContractNumbers as: <?php
declare(strict_types=1);
namespace App\TerminalData\Type;
use \App\TerminalData\Type\ArrayType;
final class TContractNumbers extends ArrayType
{
} but that arrayType don't exists. |
That looks like a bug in the code generation part indeed: <xs:complexType name="TContractNumbers">
<xs:complexContent>
<xs:restriction base="soapenc:Array">
<sequence xmlns="http://www.w3.org/2001/XMLSchema"/>
<xs:attribute ref="soapenc:arrayType" n1:arrayType="xs:string[]" xmlns:n1="http://schemas.xmlsoap.org/wsdl/"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType> Results in
Making the IsExtendingTypeRule kick in and extend The IsExtendingTypeRule should become smarter and skip some extensions like:
(reference - this logic is being used in the wsdl-reader : https://github.com/php-soap/wsdl-reader/blob/main/src/Metadata/Converter/Types/Rule/SkipArrayTypePropertiesRule.php. It's probably something to get rid of in the wsdl-reader part so that we get as good as possible meta-types and instead implement in here directly to make sure that those classes get ignored during code-generation in favour of regular array types.) |
Should I take a look and make PR? |
Sure, feel free to provide a PR. We can see where to go from there. |
I am afraid I don't even know how to start. Unfortunately my soap experience is limited. |
I can imagine, it's not an easy task to get started with I'm afraid. To fix the issue, it requires a couple of things:
Even though the 3 points above describe what needs to happen, it won't be very easy to cover all possible XSD configurations from the first try. As-in: it would probably take me around a day to fix this decently as well :) |
I have to ask. Is there any chance you would look at it in near future? |
I'm a bit limited in spare-time at the moment, so don't expect this to land in the near future from my side. https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#want-to-help-out- Feel free to reach out by mail (soap at phpro.be) if you are intereset in investing this feature into the project. |
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? |
Added this specific array issue to the list for v4 at #485. |
Hello there @RosskoDCA , I wanted to get back to this issue: We are eager to receive some early feedback on this new release. |
Support Question
I tried fixed this in this PR but it didn't work. I am not sure, if this is an issue or future request or something else, so I am asking for support.
There's WSDL document in attachment (I hope I clean up that file correctly) where is xs type
unsignedInt
For now my config looks like this:
that classmap is generated and typemap is basically the same as default one, but I added custom type for DateTime (I was dealing with this in past, the dateTime converter converts the XML to attribute with name
<dateTime>
but I needed<dateTimeFrom>
etc.)When I run the types generate command, it generates that
unsignedInt
type likebecause of this \Phpro\SoapClient\CodeGenerator\Model\Property::getType the 'usnignedInt' is not "knownType"
But it is native soap type also, which means, we can not find definition in WSDL. Now I do not know how to avoid this. I tried and succeed overriding the PropertyAssember to my own and with some dirty hack I changed that unsignedInt to int or mixed, it doesn't metter, but then I realize there's getter & setter with
App\TerminalData\Type\UnsignedInt
type also. I do not want to rewrite those assemblers too.To show I just exhaust all the options, now I have added new rule in config:
which just remove the type from that one property. But I am not satisfied with this.
Is there a way to changed
unsignedInt
to something acceptable in PHP? I mean, there's range problem with native typeint
in PHP (in 32bit systems), there's logical problem with negative numbers, and there's also logical problem with decimal places if we map that type to float.I hope I describe it understandable and I hope you can help me with this.
Daniel
attachment: terminal_data.zip
The text was updated successfully, but these errors were encountered: