WSDL - Optional Element

I’ve added an element to RegisterDisplay service and it works fine

xmdssoap4.class.php

public function RegisterDisplay($serverKey, $hardwareKey, $displayName, $clientType, $clientVersion, $clientCode, $operatingSystem, $macAddress, $dealerKey, $branchKey, $iAmNew=null) { .. ..

and also I’ve added this element to service_v4.wsdl

<message name="RegisterDisplayRequest">
        <part name="serverKey" type="xsd:string" />
        <part name="hardwareKey" type="xsd:string" />
        <part name="displayName" type="xsd:string" />
        <part name="clientType" type="xsd:string" />
        <part name="clientVersion" type="xsd:string" />
        <part name="clientCode" type="xsd:int" />
        <part name="operatingSystem" type="xsd:string" />
        <part name="macAddress" type="xsd:string" />
        <part name="dealerKey" type="xsd:string" />
        <part name="branchNo" type="xsd:string" />
        <part name="iAmNew" type="xsd:string"/>
</message>

It works fine when I add this parameter on request
But this “iAmNew” parameter must be an optional.

I’ve already made modifications on php to handle it when it comes null or empty there is no problem there. But service gives error like that : XMDS.register Missing element iAmNew (RegisterDisplay.iAmNew).

I am not familiar with soap services so i’ve made some researches. As I read the docs, I have to add “minOccurs=0” to element to make it optional something like that:

<xs:element name="iAmNew" type="xs:string" minOccurs="0" maxOccurs="1"/>

but i couldnt fine where are the defined elements, service_v4.wsdl only contains message, portType and binding.

Can you show me how to simply add an optional parameter?

I am working on v1.7.9

Thanks in advance

Hi,

Sorry but I don’t think you can do that, my understanding of the way the SoapServer works in PHP is that you can’t have optional parameters.

This is why we have a WSDL version change when we want to add parameters - you’ll see in later CMS instances that we have v5 (and a v3 for earlier).