Jump to content

Having problem with soap, Encoding: object has no '...' property in..


sjonni82

Recommended Posts

This has been driving me mad for 2 days now. Seems like the object i am creating is not working for the soap class.

I get the following error.

 

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'CreditCard' property in /var/www/vhosts/mysite.com/httpdocs/Felagakerfi/mysoap.php:114 Stack trace: #0 /var/www/vhosts/mysite.com/httpdocs/Felagakerfi/mysoap.php(114): SoapClient->__call('CreateMemberFee', Array) #1 /var/www/vhosts/mysite.com/httpdocs/Felagakerfi/signup.php(327): create_member_fee(Object(TMemberFee), '_ActionInsertEd...') #2 /var/www/vhosts/mysite.com/httpdocs/templates/ja_opal/index.php(200): include('/var/www/vhosts...') #3 /var/www/vhosts/mysite.com/httpdocs/libraries/joomla/document/html/html.php(338): require_once('/var/www/vhosts...') #4 /var/www/vhosts/mysite.com/httpdocs/libraries/joomla/document/html/html.php(246): JDocumentHTML->_loadTemplate('/var/www/vhosts...', 'index.php') #5 /var/www/vhosts/mysite.com/httpdocs/includes/application.php(168): JDocumentHTML->render('0', Array) #6 /var/www/vhosts/mysite.com/httpdocs/index.php(79): JSite->render() #7 {main} thrown in /var/www/vhosts/mysite.com/httpdocs/Felagakerfi/mysoap.php on line 114

Sometimes it is object has no 'RecordId', depending on some random changes i make.

 

Im not an experinenced PHP programmer so i dont really know whats going on after i send the parameters into the soap call function. It would be great if someone could take a look and see what im doing wrong.

 

Here is my PHP 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;
   } 
   
   class TCreditCard
   {
      public $TComboBox_ARCreditCardType;
      public $CardNumber;
      public $ExpDate;
      public $SSNumber;
      public $Name;
   }
   
   class TMemberFee 
   { 
      public $RecordID;
      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 = ''

$creditCard = new TCreditCard();
      $creditCard->TComboBox_ARCreditCardType = $_POST['cardType'];
      $creditCard->CardNumber = $_POST['ccNumber'];
      $creditCard->ExpDate = mktime(0,0,0,$_POST['cardMonth'],1,$_POST['cardYear']);
      $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 SOAP SERVICE';
     $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));
      return $result;

 

And here is the soap part i am using

 

<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>

I just solved the problem, it was silly actually. I forgot to put CreditCard property in the TMemberV2 class, i was confused by this since CreditCard is also used in TMemberFee.

I also had to change the property TComboBox_ARCreditCardType name in TCreditCard to CardType.

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));

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.