Skip to content

Encode requires elements even if minOccurs="0" #23

@samtlewis

Description

@samtlewis
Q A
Version 0.10.0

Support Question

I'm attempting to work with the follow wsdl:
https://mcrst8x716h2zwnjnll-h6xhfcf4.soap.marketingcloudapis.com/etframework.wsdl

In this particular request:

<complexType name="RetrieveRequest">
<sequence>
<element name="ClientIDs" type="tns:ClientID" minOccurs="0" maxOccurs="unbounded"/>
<element name="ObjectType" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<element name="Properties" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<element name="Filter" type="tns:FilterPart" minOccurs="0" maxOccurs="1"/>
<element name="RespondTo" type="tns:AsyncResponse" minOccurs="0" maxOccurs="unbounded"/>
<element name="PartnerProperties" type="tns:APIProperty" minOccurs="0" maxOccurs="unbounded"/>
<element name="ContinueRequest" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<element name="QueryAllAccounts" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="RetrieveAllSinceLastBatch" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="RepeatLastResult" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="Retrieves" minOccurs="0">
<complexType>
<sequence>
<element name="Request" type="tns:Request" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
<element name="Options" type="tns:RetrieveOptions" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>

many of the elements are set to minOccurs="0" which I would think would make them optional. But the encoder complains if I don't include them. I could live with that except for the "Retrieves" element as I have to include an empty "Request" element which then adds the Retrieves element to the final xml. This happens to cause an error when submitting this soap request. The call works when i remove the Retrieves element from the request.

  1. Shouldn't the minOccurs="0" mean that the elements are optional and should not have to be included when encoding the request?

Sample Code:

$wsdl = (new Wsdl1Reader(new StreamWrapperLoader()))('https://mcrst8x716h2zwnjnll-h6xhfcf4.soap.marketingcloudapis.com/etframework.wsdl');
        $driver = Driver::createFromWsdl1($wsdl);
        $encoded = $driver->encode('Retrieve', [
            [
                'RetrieveRequest' => [
                    'ClientIDs' => [],
                    'ObjectType' => 'DataExtension',
                    'Properties' => ['Name', 'CustomerKey', 'IsSendable', 'IsTestable'],
                    'Filter' => [],
                    'RespondTo' => [],
                    'PartnerProperties' => [],
                    'ContinueRequest' => null,
                    'QueryAllAccounts' => null,
                    'RetrieveAllSinceLastBatch' => null,
                    'RepeatLastResult' => null,
                    'Retrieves' => [
                        'Request' => []
                    ]
                ]
            ]
        ]);
> http://exacttarget.com/wsdl/partnerAPI:RetrieveRequest {
    array<int<0, max>, ClientID> $ClientIDs
    string $ObjectType
    array<int<0, max>, string> $Properties
    ?FilterPart $Filter
    array<int<0, max>, AsyncResponse> $RespondTo
    array<int<0, max>, APIProperty> $PartnerProperties
    ?string $ContinueRequest
    ?boolean $QueryAllAccounts
    ?boolean $RetrieveAllSinceLastBatch
    ?boolean $RepeatLastResult
    ?Retrieves $Retrieves
    ?RetrieveOptions $Options
  }

Generated XML:

<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:RetrieveRequestMsg xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">
            <tns:RetrieveRequest xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">
                <tns:ObjectType xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">DataExtension</tns:ObjectType>
                <tns:Properties xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">Name</tns:Properties>
                <tns:Properties xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">CustomerKey</tns:Properties>
                <tns:Properties xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">IsSendable</tns:Properties>
                <tns:Properties xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">IsTestable</tns:Properties>
                <tns:Filter xmlns:tns="http://exacttarget.com/wsdl/partnerAPI"></tns:Filter>
                <tns:QueryAllAccounts xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">false</tns:QueryAllAccounts>
                <tns:RetrieveAllSinceLastBatch xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">false</tns:RetrieveAllSinceLastBatch>
                <tns:RepeatLastResult xmlns:tns="http://exacttarget.com/wsdl/partnerAPI">false</tns:RepeatLastResult>
                <tns:Retrieves xmlns:tns="http://exacttarget.com/wsdl/partnerAPI"></tns:Retrieves>
            </tns:RetrieveRequest>
        </tns:RetrieveRequestMsg>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions