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
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;
}
And here is the WSDL function and complex types.
<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>
The error generated when calling create_member_fee() is like this
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'RecordID' property in...
I am relatively new at PHP and im given this massive assignment to finish before the weekend, and frankly im at a loss, if anyone can help and tell me why this error is being generated i will be greatful. The $client->__getLastRequest() does not work so i dont know how the xml in the request looks like, wich makes my life more difficult.
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));
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With