Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

michael's avatar

SOAP XML to PHP Help

Not really Laravel related (I am using Laravel though). But I am looking for help trying to translate this SOAP request XML to PHP using SoapClient. I have tried a lot of different things and the company that owns the SOAP API isn't being very helpful.

Below is the XML SOAP request that I need to try to match.

<CreateCustomerRequest xmlns="http://schemas.datacontract.org/2004/07/BillingTree.ApiService.Contract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<MerchantCredentials>
<CertId></CertId>
<Password></Password>
<UserName></UserName>
<Zid></Zid>
</MerchantCredentials>
<Customer>
<Address>
<AddressLine1>1234 Address</AddressLine1>
<AddressLine2 i:nil="true"/>
<AddressLine3 i:nil="true"/>
<City>Los Angeles</City>
<Country>USA</Country>
<Province i:nil="true"/>
<State>CA</State>
<ZipCode>85284</ZipCode>
</Address>
<Department>WOPPER</Department>
<Email>[email protected]</Email>
<Fax i:nil="true"/>
<FirstName>Joe </FirstName>
<Id></Id>
<LastName>Bob</LastName>
<Phone>12355677</Phone>
<Status>Active</Status>
<Title>Hacker Supreme</Title>
</Customer>
</CreateCustomerRequest>

This is kinda what I tried and when I dump out what the XML request is, it's not even close and not including the MerchantCredentials. I don't have a lot of SOAP experience and I am getting pretty desperate, I have spent hours trying to figure it out.

 $client = new \SoapClient('', ['trace' => 1, 'exceptions' => 0, 'soap_version' => SOAP_1_1]);

        $soapParameters = [
            'MerchantCredentials' => (object) [
                    'Zid' => '',
                    'UserName' => '',
                    'Password' => '',
                    'CertId' => '',
            ],
        'FirstName' => 'test',
        'LastName' => 'test'
        ];

        try {
            $request = $client->CreateCustomer((object) $soapParameters);
        }
        catch (SoapFault $e) {

        }
0 likes
3 replies
michael's avatar

Yeah it was more of an issue with the vendor. Hate these older vendors that require SOAP.

2 likes

Please or to participate in this conversation.