Soap error, Encoding: object has no 'RecordId' property

后端 未结 5 1760
情话喂你
情话喂你 2021-01-05 08:00

I am doing a registration form online that connects to a soap web service and should be able to save payment information through it. The PHP is like this

            


        
相关标签:
5条回答
  • 2021-01-05 08:25

    See also https://bugs.php.net/bug.php?id=50997 - it looks like you hit that bug - namely PHP seems to have problems with sequences when not using objects.

    0 讨论(0)
  • 2021-01-05 08:29

    I just solved the problem, it was a matter of using objects instead of the huge and confusing array. You must hoewer not forget to map the objects exactly as they appear in the wsdl. And you must assign value to all of them in your instance, if emty just use ''. Here is my code.

        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));
    
    0 讨论(0)
  • 2021-01-05 08:36

    I was once puzzeled by an error like this. It turned out the property wasn't missing in the request but in the response. The error message did not contain any specification.

    0 讨论(0)
  • 2021-01-05 08:42

    Define all the fields he's claiming as "Missing property"

    So if you're using an array, and it says it's missing property 'GetData', do:

    $requestArray['GetData'] = '';

    and so on with each field, until it's working.

    0 讨论(0)
  • 2021-01-05 08:49

    The best way without having to declare classes is to use the stdClass. To make it work, preserve the name of the fields in your object and object properties.

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

    This worked for me, I hope it works for you.

    0 讨论(0)
提交回复
热议问题