简体   繁体   中英

Post data to SOAP API with PHP

I want you to help me with a solution on how I could post the data below to a soap endpoint, am used to json I want the oupput in json format. Please help. thanks

<?xml version="1.0" encoding="UTF- 
    8"?>
<soapenv:Envelope 


xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cib="http://com.xxxxx.com/custom/cibupload" xmlns:cib1="http://xxx.xxx.org/xxx/07/CIBUploadService.Models">
<soapenv:Header />
<soapenv:Body>
    <cib:SendRequest>
        <!--Optional:-->
        <cib:data>
            <!--Optional:-->
            <cib1:BulkDebitReference>?</cib1:BulkDebitReference>
            <!--Optional:-->
            <cib1:ClientInfo>
                <!--Optional:-->
                <cib1:CompanyCode>CIB001484</cib1:CompanyCode>
                <!--Optional:-->
                <cib1:Password>pass*145%83078</cib1:Password>
                <!--Optional:-->
                <cib1:UserID>test_user</cib1:UserID>
            </cib1:ClientInfo>
            <!--Optional:-->
            <cib1:MAC />
            <!--Optional:-->
            <cib1:TransactionRequest>
                <!--Zero or more repetitions:-->
                <cib1:Transaction>
                    <!--Optional:-->
                    <cib1:Amount>2000</cib1:Amount>
                    <!--Optional:-->
                    <cib1:BeneficiaryAccount>1020047624</cib1:BeneficiaryAccount>
                    <!--Optional:-->
                    <cib1:BeneficiaryAddress />
                    <!--Optional:-->
                    <cib1:BeneficiaryBankCode>057</cib1:BeneficiaryBankCode>
                    <!--Optional:-->
                    <cib1:BeneficiaryBankSortCode />
                    <!--Optional:-->
                    <cib1:BeneficiaryCategory />
                    <!--Optional:-->
                    <cib1:BeneficiaryCode />
                    <!--Optional:-->
                    <cib1:BeneficiaryEmail />
                    <!--Optional:-->
                    <cib1:BeneficiaryMobile />
                    <!--Optional:-->
                    <cib1:BeneficiaryName>JOHN UBAH</cib1:BeneficiaryName>
                    <!--Optional:-->
                    <cib1:BeneficiaryPhone />
                    <!--Optional:-->
                    <cib1:ContractDate />
                    <!--Optional:-->
                    <cib1:ContractNo />
                    <!--Optional:-->
                    <cib1:DebitAccount>2020076821</cib1:DebitAccount>
                    <!--Optional:-->
                    <cib1:DebitAccountName />
                    <!--Optional:-->
                    <cib1:DebitCurrency>NGN</cib1:DebitCurrency>
                    <!--Optional:-->
                    <cib1:InvoiceNumber />
                    <!--Optional:-->
                    <cib1:PaymentCurrency />
                    <!--Optional:-->
                    <cib1:PaymentMethod />
                    <!--Optional:-->
                    <cib1:PaymentType />
                    <!--Optional:-->
                    <cib1:Payment_Due_Date>07/01/2019</cib1:Payment_Due_Date>
                    <!--Optional:-->
                    <cib1:TransactionRef>CIB/MONU/BD/1873</cib1:TransactionRef>
                </cib1:Transaction>
            </cib1:TransactionRequest>
            <!--Optional:-->
            <cib1:UseSingleDebitMultipleCredit>false</cib1:UseSingleDebitMultipleCredit>
        </cib:data>
    </cib:SendRequest>
</soapenv:Body>

Blockquote

The above is the XML version of the request, as I have tried to communicate with it using my json experience but it ain't really help because I am still at engineer level.

You should start by looking to the native PHP SoapClient class at http://php.net/manual/en/class.soapclient.php . Try to understand how it works.

As you seem to have a pretty complexe request, I would then recommend you to use a WSDL to PHP generator. It'll allow you to use a full OOP approach which is better and easier. Try the https://github.com/WsdlToPhp/PackageGenerator project, it'll ease the request construction and the request handling all with PHP objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM