We have an application that builds a correct XML request in SimpleXML. When outputting this with $element->asXml() I also get the correct XML. However when passing the SimpleXML object to the soapclient it will stripp all keys in array's.
I have tried several ways to fix this. Assigning keys to the elements. Several Soapclient features, and turning everything into an array. No result.
This is a abstract version of what i'm trying to achieve.
$populate = new SimpleXMLElement('<Populate/>');
$data = $populate->addChild('data');
$roleKeysElement = $data->addChild('RoleKeys');
$roleKeysElement->addChild('Operation', $settings[PopulateSettings::ROLE_KEYS] ?? Operations::MIRROR);
$roleKeyElement1 = $roleKeysElement->addChild('RoleKey');
$keyElement1 = $roleKeyElement1->addChild('Key');
$certificateElement = 1->addChild('Certificate');
$certificateElement->addChild('ValidUntil', 1);
$certificateElement->addChild('Password', 2);
$certificateElement->addChild('Thumbprint', 3);
$certificateElement->addChild('Serial', 4);
$certificateElement->addChild('Base64Data', 5);
$roleKeyElement2 = $roleKeysElement->addChild('RoleKey');
$keyElement2 = $roleKeyElement2->addChild('Key');
$certificateElement = $keyElement2->addChild('Certificate');
$certificateElement->addChild('ValidUntil', 1);
$certificateElement->addChild('Password', 2);
$certificateElement->addChild('Thumbprint', 3);
$certificateElement->addChild('Serial', 4);
$certificateElement->addChild('Base64Data', 5);
$response = $this->client->populate($populate);
My WSDL has maxOccurence=Unbound for certifcate in this case. But only 1 certifcate object is send. Only the first one.
What im getting from the simpleXML asXml() function is
<Populate>
<data>
<RoleKeys>
<Operation>
Mirror
</Operation>
<RoleKey>
<Key>
<Certificate>
<ValidUntil>
1
</ValidUntil>
<Password>
2
</Password>
<Thumbprint>
3
</Thumbprint>
<Serial>
4
</Serial>
<Base64Data>
5
</Base64Data>
</Certificate>
</Key>
</RoleKey>
<RoleKey>
<Key>
<Certificate>
<ValidUntil>
1
</ValidUntil>
<Password>
2
</Password>
<Thumbprint>
3
</Thumbprint>
<Serial>
4
</Serial>
<Base64Data>
5
</Base64Data>
</Certificate>
</Key>
</RoleKey>
</RoleKeys>
</data>
</Populate>
This is correct
How ever the soap clients sends
<Populate>
<data>
<RoleKeys>
<Operation>
Mirror
</Operation>
<RoleKey>
<Key>
<Certificate>
<ValidUntil>
1
</ValidUntil>
<Password>
2
</Password>
<Thumbprint>
3
</Thumbprint>
<Serial>
4
</Serial>
<Base64Data>
5
</Base64Data>
</Certificate>
</Key>
</RoleKey>
</RoleKeys>
</data>
</Populate>
To give a little more context here is the WSDL part of this request
<complexType name="KeyType">
<sequence>
<element minOccurs="0" maxOccurs="1" name="KeyUnlocks" type="s:string" />
<choice minOccurs="1" maxOccurs="1">
<element minOccurs="0" maxOccurs="1" name="Credentials">
<complexType>
<sequence>
<element minOccurs="0" maxOccurs="1" name="Username" type="s:string" />
<element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</sequence>
</complexType>
</element>
<element minOccurs="0" maxOccurs="1" name="Certificate">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="ValidUntil" type="s:dateTime" />
<element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
<element minOccurs="0" maxOccurs="1" name="Thumbprint" type="s:string" />
<element minOccurs="0" maxOccurs="1" name="Serial" type="s:string" />
<element minOccurs="0" maxOccurs="1" name="Base64Data" type="s:base64Binary" />
</sequence>
</complexType>
</element>
</choice>
</sequence>
</complexType>
from SoapClient not rendering correct xml from SimpleXMLObject
No comments:
Post a Comment