Sapone errore di Codifica: oggetto non ha ‘RecordId di proprietà

Io sto facendo un form di registrazione online che si connette a un servizio web soap e dovrebbe essere in grado di salvare le informazioni di pagamento attraverso di essa.
Il PHP è come questo

    function create_member_fee()
      {
        $wsdl = 'WSDL LOCATION';
        $client = new mySoap($wsdl, array('trace' => 1));
        $request = array(
           'obj'=>array(
                  'Member'=>array('Number'=>$NUMBER),
                  'Amount'=>$PRICE,
                  'CreditCard'=>array(
                                'TComboBox_ARCreditCardType'=>$_POST['CT'],
                                'CardNumber'=>$_POST['CN'],
                                'ExpDate'=>mktime(0,0,0,$_POST['CM'],1,$_POST['CY']),
                                'SSNumber'=>$NUMBER_PAYER
                                )
             ),
           'opt'=>array('MemberAction'=>new SoapParam('_ActionInsert','ns1:TActionMethod'))
          );
        $result = $client->__call('CreateMemberFee',$request);
        return $result;
      }

E qui è il WSDL funzione e tipi complessi.

<message name="CreateMemberFee85Request">
<part name="obj" type="ns1:TMemberFee"/>
<part name="opt" type="ns1:TMemberFeeOptions"/>
</message>

<xs:complexType name="TMemberFee">
<xs:sequence>
<xs:element name="Member" type="ns1:TMemberV2"/>
<xs:element name="Payer" type="ns1:TPerson"/>
<xs:element name="ItemCode" type="xs:string"/>
<xs:element name="Amount" type="xs:double"/>
<xs:element name="CreditCard" type="ns1:TCreditCard"/>
<xs:element name="Saleperson" type="xs:string"/>
<xs:element name="ContactName" type="xs:string"/>
<xs:element name="DiscountPercent" type="xs:double"/>
<xs:element name="ReductionPayment" type="xs:double"/>
<xs:element name="DiscountValidUntil" type="xs:dateTime"/>
<xs:element name="PaymentTerm" type="xs:string"/>
<xs:element name="PaymentMode" type="xs:string"/>
<xs:element name="Memo" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="TMemberV2">
<xs:sequence>
<xs:element name="RecordID" type="xs:int"/>
<xs:element name="Number" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="SSNumber" type="xs:string"/>
<xs:element name="Address1" type="xs:string"/>
<xs:element name="Address2" type="xs:string"/>
<xs:element name="Address3" type="xs:string"/>
<xs:element name="Address4" type="xs:string"/>
<xs:element name="ZipCode" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="CountryCode" type="xs:string"/>
<xs:element name="CountryName" type="xs:string"/>
<xs:element name="CountyCode" type="xs:string"/>
<xs:element name="Phone" type="xs:string"/>
<xs:element name="PhoneLocal" type="xs:string"/>
<xs:element name="PhoneMobile" type="xs:string"/>
<xs:element name="PhoneFax" type="xs:string"/>
<xs:element name="Telex" type="xs:string"/>
<xs:element name="Email" type="xs:string"/>
<xs:element name="Password" type="xs:string"/>
<xs:element name="Group" type="xs:string"/>
<xs:element name="Tag" type="xs:string"/>
<xs:element name="SalesPerson" type="xs:string"/>
<xs:element name="Discount" type="xs:double"/>
<xs:element name="ItemReceivers" type="ns1:ArrayOfItemReceiver"/>
<xs:element name="Contacts" type="ns1:ArrayOfContacts"/>
<xs:element name="PaymentType" type="xs:string"/>
<xs:element name="CurrencyCode" type="xs:string"/>
<xs:element name="NoVat" type="xs:boolean"/>
<xs:element name="LedgerCode" type="xs:string"/>
<xs:element name="RecordCreated" type="xs:dateTime"/>
<xs:element name="RecordModified" type="xs:dateTime"/>
<xs:element name="Blocked" type="xs:boolean"/>
<xs:element name="Dead" type="xs:boolean"/>
<xs:element name="Retierd" type="xs:boolean"/>
<xs:element name="Disabled" type="xs:boolean"/>
<xs:element name="Points" type="xs:double"/>
<xs:element name="BankCode" type="xs:string"/>
<xs:element name="BankAccGroup" type="xs:string"/>
<xs:element name="BankAccount" type="xs:string"/>
<xs:element name="MemberSubGroups" type="ns1:ArrayOfMemberSubGroups"/>
<xs:element name="Carrer" type="ns1:ArrayOfMemberCarrer"/>
<xs:element name="Membership" type="ns1:ArrayOfMemberMemberships"/>
<xs:element name="Education" type="ns1:ArrayOfMemberEducations"/>
<xs:element name="Applications" type="ns1:ArrayOfMemberApplication"/>
<xs:element name="Funds" type="ns1:ArrayOfMemberFunds"/>
<xs:element name="CreditCard" type="ns1:TCreditCard"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="TPerson">
<xs:sequence>
<xs:element name="Number" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="SSNumber" type="xs:string"/>
<xs:element name="Address1" type="xs:string"/>
<xs:element name="Address2" type="xs:string"/>
<xs:element name="Address3" type="xs:string"/>
<xs:element name="Address4" type="xs:string"/>
<xs:element name="ZipCode" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="CountryCode" type="xs:string"/>
<xs:element name="CountryName" type="xs:string"/>
<xs:element name="CountyCode" type="xs:string"/>
<xs:element name="Phone" type="xs:string"/>
<xs:element name="PhoneLocal" type="xs:string"/>
<xs:element name="PhoneMobile" type="xs:string"/>
<xs:element name="PhoneFax" type="xs:string"/>
<xs:element name="Email" type="xs:string"/>
<xs:element name="RecordCreated" type="xs:dateTime"/>
<xs:element name="RecordModified" type="xs:dateTime"/>
<xs:element name="Blocked" type="xs:boolean"/>
<xs:element name="Gender" type="ns1:TGender"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="TCreditCard">
<xs:sequence>
<xs:element name="CardType" type="ns2:TComboBox_ARCreditCardType"/>
<xs:element name="CardNumber" type="xs:string"/>
<xs:element name="ExpDate" type="xs:dateTime"/>
<xs:element name="SSNumber" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="TMemberFeeOptions">
<xs:sequence>
<xs:element name="MemberAction" type="ns1:TActionMethod"/>
</xs:sequence>
</xs:complexType>

<xs:simpleType name="TActionMethod">
<xs:restriction base="xs:string">
<xs:enumeration value="_ActionUse"/>
<xs:enumeration value="_ActionInsert"/>
<xs:enumeration value="_ActionEdit"/>
<xs:enumeration value="_ActionInsertEdit"/>
<xs:enumeration value="_ActionInsertMerge"/>
<xs:enumeration value="_ActionUseInsert"/>
</xs:restriction>
</xs:simpleType>

L’errore generato quando si chiama create_member_fee() è come questo

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'RecordID' property in...

Io sono relativamente nuovo in PHP e im data questa enorme assegnazione di finire prima del fine settimana, e francamente im in perdita, se qualcuno può aiutarmi e dirmi il perchè di questo errore viene generato sarò grato. $Client->__getLastRequest() non funziona così non so come xml nella richiesta sembra, che rende la mia vita più difficile.

Mi dispiace non farlo.

OriginaleL’autore user923256 | 2011-09-01

5 Replies
  1. 5

    Ho appena risolto il problema, era una questione di usare oggetti al posto dell’enorme e confuso. Si deve hoewer non dimenticate di mappare gli oggetti esattamente come appaiono nel wsdl. E si deve assegnare il valore di tutti loro nel tuo esempio, se emty solo l’uso “. Ecco il mio codice.

        class TMemberV2 
            { 
                public $RecordID;
                public $Number;
                public $Name;
                public $SSNumber;
                public $Address1;
                public $Address2;
                public $Address3;
                public $Address4;
                public $ZipCode;
                public $City;
                public $CountryCode;
                public $CountryName;
                public $CountyCode;
                public $Phone;
                public $PhoneLocal;
                public $PhoneMobile;
                public $PhoneFax;
                public $Telex;
                public $Email;
                public $Password;
                public $Group;
                public $Tag;
                public $SalesPerson;
                public $Discount;
                public $ItemReceivers;
                public $Contacts;
                public $PaymentType;
                public $CurrencyCode;
                public $NoVat;
                public $LedgerCode;
                public $RecordCreated;
                public $RecordModified;
                public $Blocked;
                public $Dead;
                public $Retierd;
                public $Disabled;
                public $Points;
                public $BankCode;
                public $BankAccGroup;
                public $BankAccount;
                public $MemberSubGroups;
                public $Carrer;
                public $Membership;
                public $Education;
                public $Applications;
                public $Funds;
                public $CreditCard;
            } 
    
            class TCreditCard
            {
                public $CardType;
                public $CardNumber;
                public $ExpDate;
                public $SSNumber;
                public $Name;
            }
    
            class TMemberFee 
            { 
                public $Member;
                public $Payer;
                public $ItemCode;
                public $Amount;
                public $CreditCard;
                public $Saleperson;
                public $ContactName;
                public $DiscountPercent;
                public $DiscountValidUntil;
                public $PaymentTerm;
                public $PaymentMode;
                public $Memo;
            } 
    
            $member = new TMemberV2(); 
                    $member->RecordID = $id;
                    $member->Number = $kennitala;
                    $member->Name = $nafn;
                    $member->SSNumber = $kennitala;
                    $member->Address1 = $heimilisfang;
                    $member->Address2 = '';
                    $member->Address3 = '';
                    $member->Address4 = '';
                    $member->ZipCode = $postnumer;
                    $member->City = $sveitarfelag;
                    $member->CountryCode = 'IS';
                    $member->CountryName = 'Ísland';
                    $member->CountryCode = 'IS';
                    $member->Phone = $simanumer;
                    $member->PhoneLocal = '';
                    $member->PhoneMobile = $farsimi;
                    $member->PhoneFax = '';
                    $member->Telex = '';
                    $member->Email = $netfang;
                    $member->Password = '';
                    $member->Group = '';
                    $member->Tag = '';
                    $member->SalesPerson = '';
                    $member->Discount = '$';
                    $member->ItemReceivers = '';
                    $member->Contacts = '';
                    $member->PaymentType = 'test';
                    $member->CurrencyCode = '';
                    $member->NoVat = '';
                    $member->LedgerCode = '';
                    $member->RecordCreated = '';
                    $member->RecordModified = '';
                    $member->Blocked = '';
                    $member->Dead = '';
                    $member->Retierd = '';
                    $member->Disabled = '';
                    $member->Points = '';
                    $member->BankCode = '';
                    $member->BankAccGroup = '';
                    $member->BankAccount = '';
                    $member->MemberSubGroups = '';
                    $member->Carrer = '';
                    $member->Membership = '';
                    $member->Education = '';
                    $member->Applications = '';
                    $member->Funds = '';
                    $member->CreditCard = '';
    
    $creditCard = new TCreditCard();
            $creditCard->CardType = $_POST['CT'];
            $creditCard->CardNumber = $_POST['CN'];
            $creditCard->ExpDate = mktime(0,0,0,$_POST['CM'],1,$_POST['CY']);
            $creditCard->SSNumber = $kt_forradamanns;
    
            $memberFee = new TMemberFee();
            $memberFee->Member = $member;
            $memberFee->Payer = '';
            $memberFee->ItemCode = '';
            $memberFee->Amount = $namskeid_verd;
            $memberFee->CreditCard = $creditCard;
            $memberFee->Saleperson = '';
            $memberFee->ContactName = '';
            $memberFee->DiscountPercent = '';
            $memberFee->ReductionPayment = '';
            $memberFee->DiscountValidUntil = strtotime("now");
            $memberFee->PaymentTerm = '';
            $memberFee->PaymentMode = '';
            $memberFee->Memo = '';
    
    $wsdl = 'SOME WSDL';
        $client = new mySoap($wsdl, array('trace' => 1));
        $param = new SoapParam($memberFee, 'ns1:TMemberFee');
        $param1 = new SoapParam('_ActionInsertEdit', 'ns1:TMemberFeeOptions');
            $result = $client->__call('CreateMemberFee',array('obj'=>$param, 'opt'=>$param1));
    Che cosa dovrebbe server.php fare, quando si ricevono questi $wsdl = 'SOME WSDL'; $client = new mySoap($wsdl, array('trace' => 1)); $param = new SoapParam($memberFee, 'ns1:TMemberFee'); $param1 = new SoapParam('_ActionInsertEdit', 'ns1:TMemberFeeOptions'); $result = $client->__call('CreateMemberFee',array('obj'=>$param, 'opt'=>$param1));

    OriginaleL’autore user923256

  2. 4

    Il modo migliore, senza dover dichiarare classi è quello di utilizzare il stdClass. Per farlo funzionare, conservano il nome dei campi del tuo oggetto e le proprietà dell’oggetto.

        $TMemberFee = new stdClass();
        $TMemberV2 = new stdClass();
        ...
        $TMemberV2->RecordID = $id_holder_var;
    
        ...
        $TMemberFee->Member = $TMemberV2;
        ...

    Questo ha funzionato per me, spero che funziona per voi.

    Grazie, questo mi ha veramente aiutato!

    OriginaleL’autore Cristian

  3. 3

    Definire tutti i campi di lui, sostenendo come “Mancante proprietà”

    Quindi, se si utilizza una matrice, e si dice che è mancante di proprietà ‘GetData’:

    $requestArray[‘GetData’] = “;

    e così via con ogni campo, fino a quando non lavoro.

    OriginaleL’autore Duccio

  4. 1

    Una volta ero puzzeled da un errore come questo. Si è scoperto che la proprietà non era mancanti nella richiesta, ma nella risposta. Il messaggio di errore non contiene alcuna specificazione.

    OriginaleL’autore allrounder

Lascia un commento