-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Explicitly specifying a type #534
Comments
References to #369 |
Can you provide the WSDL for this service? |
It's not public, but I can provide necessary chunks of WSDL. <wsdl:definitions
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://parsec.ru/Parsec3IntergationService"
xmlns:s1="http://microsoft.com/wsdl/types/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://parsec.ru/Parsec3IntergationService">
<s:complexType name="ArrayOfExtraFieldValue">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="ExtraFieldValue" nillable="true" type="tns:ExtraFieldValue"/>
</s:sequence>
</s:complexType>
<s:complexType name="ExtraFieldValue">
<s:complexContent mixed="false">
<s:extension base="tns:BaseObject">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="TEMPLATE_ID" type="s1:guid"/>
<s:element minOccurs="0" maxOccurs="1" name="VALUE"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:element name="SetPersonExtraFieldValue">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="personEditSessionID" type="s1:guid"/>
<s:element minOccurs="1" maxOccurs="1" name="templateID" type="s1:guid"/>
<s:element minOccurs="0" maxOccurs="1" name="value"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SetPersonExtraFieldValues">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="personEditSessionID" type="s1:guid"/>
<s:element minOccurs="0" maxOccurs="1" name="values" type="tns:ArrayOfExtraFieldValue"/>
</s:sequence>
</s:complexType>
</s:element>
</wsdl:definitions> |
Hello @LazyTechwork, That's not a parsable wsdl. Can you try something like this: use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\SimpleType\ScalarTypeEncoder;
use Soap\Encoding\Encoder\XmlEncoder;
use VeeWee\Reflecta\Iso\Iso;
$registry->addSimpleTypeConverter(
'http://www.w3.org/2001/XMLSchema',
'anyType',
new class implements XmlEncoder {
public function iso(Context $context): Iso
{
return (new ScalarTypeEncoder())->iso(new Context(
$context->type,
$context->metadata,
$context->registry,
$context->namespaces,
BindingUse::ENCODED
));
}
}
); When the BindingUse is set to If this works, We could add a |
I added this and got |
Here it is: https://pastebin.com/7MNiHgBQ |
Hello, The error you are getting is most likely because an invalid value gets passed in. I've quickly set up a POC and this seems to not throw any errors: <?php
use Soap\Encoding\Driver;
use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\SimpleType\ScalarTypeEncoder;
use Soap\Encoding\Encoder\XmlEncoder;
use Soap\Encoding\EncoderRegistry;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\WsdlReader\Locator\ServiceSelectionCriteria;
use Soap\WsdlReader\Model\Definitions\BindingUse;
use Soap\WsdlReader\Wsdl1Reader;
use VeeWee\Reflecta\Iso\Iso;
require_once __DIR__ . '/vendor/autoload.php';
$wsdl = (new Wsdl1Reader(new StreamWrapperLoader()))('parsec.wsdl');
$driver = Driver::createFromWsdl1(
$wsdl,
ServiceSelectionCriteria::defaults(),
$registry = EncoderRegistry::default(),
);
$registry->addSimpleTypeConverter(
'http://www.w3.org/2001/XMLSchema',
'anyType',
new class implements XmlEncoder {
public function iso(Context $context): Iso
{
return (new ScalarTypeEncoder())->iso(new Context(
$context->type,
$context->metadata,
$context->registry,
$context->namespaces,
BindingUse::ENCODED
));
}
}
);
$encoded = $driver->encode('SetPersonExtraFieldValue', [
[
'personEditSessionID' => '962bf124-2b58-4ed3-b63f-adaa73a29e91',
'templateID' => 'dcf55649-10d0-4572-a61b-2b804f5a25a1',
'value' => 789,
]
]);
dump($encoded); However, it is still not able to add the xsi:type because the ElementEncoder gets wrapped around it as a parent encoder before encoding the actual value. So in order for this to work, I'll most likely need to add a feature like Will try to pick it up later this week and keep you posted on the mather. |
Hello @LazyTechwork, I've made some changes to the encoding package to make this possible. You can also find the code you need to get this <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<tns:SetPersonExtraFieldValue xmlns:tns="http://parsec.ru/Parsec3IntergationService">
<tns:personEditSessionID xmlns:tns="http://parsec.ru/Parsec3IntergationService">
962bf124-2b58-4ed3-b63f-adaa73a29e91
</tns:personEditSessionID>
<tns:templateID xmlns:tns="http://parsec.ru/Parsec3IntergationService">
dcf55649-10d0-4572-a61b-2b804f5a25a1
</tns:templateID>
<value xmlns:s="http://www.w3.org/2001/XMLSchema" xsi:type="s:int"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">789
</value>
</tns:SetPersonExtraFieldValue>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
Just noticed the value element is not prefixed anymore. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<tns:SetPersonExtraFieldValue xmlns:tns="http://parsec.ru/Parsec3IntergationService">
<tns:personEditSessionID xmlns:tns="http://parsec.ru/Parsec3IntergationService">
962bf124-2b58-4ed3-b63f-adaa73a29e91
</tns:personEditSessionID>
<tns:templateID xmlns:tns="http://parsec.ru/Parsec3IntergationService">
dcf55649-10d0-4572-a61b-2b804f5a25a1
</tns:templateID>
<tns:value xmlns:s="http://www.w3.org/2001/XMLSchema" xsi:type="s:int"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://parsec.ru/Parsec3IntergationService">789
</tns:value>
</tns:SetPersonExtraFieldValue>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
@veewee Thank you very much! It really works! |
Support Question
Hello! My WSDL provider asked me to explicitly specify the type of request parameter.
Example request (here value has
xsi:type
attribute withxsd:string
value):I tried this:
But I am getting this exception:
Failed encoding type LazyTechwork\\Parsec\\Types\\SetPersonExtraFieldValue as {http://parsec.ru/Parsec3IntergationService:setpersonextrafieldvalue}. Failed at path \"SetPersonExtraFieldValue.value\".
If I simply pass a string value as a parameter, I see this in system:
System.Xml.XmlNode[]
The text was updated successfully, but these errors were encountered: