Charles Bryant
Charles Bryant

Reputation: 1025

PHP SoapClient, wsdl has required field but is not actually required

Ok so another PHP SoapClient question, and you guessed it accessing a .net wsdl.

I am accessing a soap service, that has elements that have min requires of 1, so if you omit these from php SoapClient it throws an error saying the element is not present.

If I do supply them / supply a null value / pass empty value the soap service in question throws an error. The parameter in question is a boolean.

How ever when I send a request via SoapUI with out the parameters in the xml, I get a valid response back.

Also had a friend try this in .net, the object's parameter in question had a default value of null. My friend has told me a sting in .net has a default null value but a boolean does not?

I am confused as to what I should try, currently using the deprecated __call method?

Update:

The section in the wsdl is as follows:

<s:complexType name="BankDetails">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="AccountName" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="AccountNumber" type="s:string"/>
        <s:element minOccurs="1" maxOccurs="1" name="Amex" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="ChequeCard" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="CreditLimit" type="s:decimal"/>
        <s:element minOccurs="1" maxOccurs="1" name="CurrentAccount" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="DepositAccount" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Diners" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="DirectDebit" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="JointAccount" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Mastercard" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Months" type="s:int"/>
        <s:element minOccurs="1" maxOccurs="1" name="MortgageAccount" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="OtherCard" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="PaymentBookRequired" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Storecard" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Visa" type="s:boolean"/>
        <s:element minOccurs="1" maxOccurs="1" name="Years" type="s:int"/>
    </s:sequence>
</s:complexType>

The request that was successful I sent in Soap UI was:

<BankDetails>
    <CurrentAccount>true</CurrentAccount>
    <Months>0</Months>
    <Years>3</Years>
</BankDetails>

Upvotes: 0

Views: 1045

Answers (1)

NCoder
NCoder

Reputation: 335

Assuming you're passing XML, try removing the whole element that's empty. For instance if it's breaking on because you have it empty just remove that whole line. Most WSDLs don't like to receive a line that is empty. They would either rather have something inside it, or not have that line at all.

Alternatively try passing a false boolean.

Upvotes: 1

Related Questions