title: How can I validate value in SOAP response in PHP?
body: <p>I'm working with WSDL endpoint. And I'm fairly new to SOAP clients and I've hit a road block with some of the values integrating with the XML.</p>
  
  <p>I have partial snippets that relates to the data I'm trying to pass. Below</p>
  
  <pre><code>    &lt;s:element name="CreateLoan2"&gt;
  &lt;s:complexType&gt;
  &lt;s:sequence&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Auth" type="tns:IntegrationAuthentication"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Borrower" type="tns:ArrayOfBorrower"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Broker" type="tns:Broker"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Property" type="tns:ArrayOfProperty"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="LenderCaseId" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="LoanOfficerId" type="s:int"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="EntityName" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="PrePaymentPenaltyMonths" type="s:int"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="DealDescription" type="s:string"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Program" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="LoanAmount" type="s:double"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="RequestedCloseDate" nillable="true" type="s:dateTime"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="InterestRate" type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="TermMonths" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="OriginationPoints" type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="BrokerPoints" type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="InterestPaymentReservesType" type="tns:InterstReservesType"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="PurchaseFundsDisbursedAtClosing" type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="RehabFundsDisbursedAtClosing" type="s:decimal"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="investorName" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="Holdback" type="s:double"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="DrawInterestType" type="tns:DrawInterestType"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="PointsRolled" type="s:boolean"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="InterestReservesRolled" type="s:boolean"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="Milestone" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="TriMergeCreditScore" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="LastPulledCreditDate" nillable="true" type="s:dateTime"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="LONote" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="RecentlyPreApproved" nillable="true" type="s:boolean"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="ExitStrategy" nillable="true" type="tns:ExitStrategy"/&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="ReferralSource" type="s:string"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="PlanToEscrowTaxesAndInsurance" nillable="true" type="s:boolean"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="OtherPropertiesCurrentlyUnderContract" nillable="true"     type="s:boolean"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="CashAvailableToClose" nillable="true" type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="NumberRehabsInLast6Months" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="NumberRehabsInLast12Months" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="NumberRehabsInLast24Months" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="NumberRehabsInLast60Months" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="CurrentNumberRehabsInProgress" nillable="true" type="s:int"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="ExistingHardPrivateMoneyLoansBalance" nillable="true"     type="s:decimal"/&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="MonthlyPaymentAmntExistingHardPrivateMoneyLoans" nillable="true"     type="s:decimal"/&gt;
  &lt;/s:sequence&gt;
  &lt;/s:complexType&gt;
  &lt;/s:element&gt;
  </code></pre>
  
  <p>Further down we have</p>
  
  <pre><code>&lt;s:simpleType name="InterstReservesType"&gt;
  &lt;s:restriction base="s:string"&gt;
  &lt;s:enumeration value="Percent"/&gt;
  &lt;s:enumeration value="Months"/&gt;
  &lt;/s:restriction&gt;
  &lt;/s:simpleType&gt;
  </code></pre>
  
  <p>The error I'm experiencing is <code>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (2, 617). ---&gt; System.InvalidOperationException: Instance validation error: 'Array' is not a valid value for InterstReservesType.</code></p>
  
  <p>My code is as follows</p>
  
  <pre><code> $url = 'someservice.com/serviceprovider.asmx?WSDL';
   $soapclient = new soapClient($url);
   $param = array(
      'CustomerId'=&gt;'1', 
      'IntegrationKey'=&gt;'2erf13rsdfsdfsdfw2', 
      'LoanOfficerId'=&gt;'21sdfs978',
      'PrePaymentPenaltyMonths'=&gt;'2',
      'LoanAmount'=&gt;'33200',
      'InterestRate'=&gt;'3.45', 
      'TermMonths'=&gt;'34',
      'OriginationPoints'=&gt;'123',
      'BrokerPoints'=&gt;'1254',
      'InterestPaymentReservesType'=&gt; array('Percent'=&gt;'1231', 'Months'=&gt;'123'),
      'InterstReservesType'=&gt;'sdfsd',
      'PurchaseFundsDisbursedAtClosing'=&gt;'123123.11' ,
      'RehabFundsDisbursedAtClosing'=&gt;'1232',
      'Holdback'=&gt;'123',
      'DrawInterestType'=&gt;'',
      'PointsRolled'=&gt;'',
      'InterestReservesRolled'=&gt;'',
      'Milestone'=&gt;'',
      'TriMergeCreditScore'=&gt;'',
      'LastPulledCreditDate'=&gt;'',
      'LONote'=&gt;'',
      'RecentlyPreApproved'=&gt;'',
      'ExitStrategy'=&gt;'',
      'ReferralSource'=&gt;'',
      'PlanToEscrowTaxesAndInsurance'=&gt;'',
      'OtherPropertiesCurrentlyUnderContract'=&gt;'',
      'CashAvailableToClose'=&gt;'',
      'NumberRehabsInLast6Months'=&gt;'',
      'NumberRehabsInLast12Months'=&gt;'',
      'NumberRehabsInLast24Months'=&gt;'',
      'NumberRehabsInLast60Months'=&gt;'',
      'CurrentNumberRehabsInProgress'=&gt;'',
      'ExistingHardPrivateMoneyLoansBalance'=&gt;'',
      'MonthlyPaymentAmntExistingHardPrivateMoneyLoans'=&gt;''
      );
   $response = $soapclient-&gt;CreateLoan2($param);
  
   var_dump($response);
  
   $array = json_decode(json_encode($response), true);
   print_r($array);
   }catch(Exception $e){
      echo '&lt;pre&gt;';
      echo $e-&gt;getMessage();
      echo '&lt;/pre&gt;';
   }
  </code></pre>
  
  <p>The idea is to submit the data to create a loan with the values retrieved from the form submission. Any help and any advice I would greatly appreciate it or if you need more info. Thanks.</p>
  
  <p>EDIT:</p>
  
  <pre><code>&lt;Borrower&gt;
      &lt;Borrower&gt;
        &lt;first_name&gt;string&lt;/first_name&gt;
        &lt;middle_name&gt;string&lt;/middle_name&gt;
        &lt;last_name&gt;string&lt;/last_name&gt;
        &lt;primary_phone&gt;string&lt;/primary_phone&gt;
        &lt;email&gt;string&lt;/email&gt;
        &lt;ssn&gt;string&lt;/ssn&gt;
        &lt;is_guarantor&gt;boolean&lt;/is_guarantor&gt;
        &lt;lender_API_id&gt;string&lt;/lender_API_id&gt;
        &lt;BorrowerResidenceOwnershipPaymentType&gt;Mortgage or Rent or PaidOff or Other&lt;/BorrowerResidenceOwnershipPaymentType&gt;
      &lt;/Borrower&gt;
  &lt;/Borrower&gt;
  </code></pre>