'How to send parameters in soap request in php in __soapcall() function
i want to send a below xml request to the server which is sending ok by using soap UI but not in php:
<ns:AgentLogin>
<ns:AgentLoginRQ>
<ns:Authentication>
<ns:DBName>************</ns:DBName>
<ns:IP>************</ns:IP>
</ns:Authentication>
<ns:AgentABTA>************</ns:AgentABTA>
<ns:UserName>************</ns:UserName>
<ns:Password>************</ns:Password>
</ns:AgentLoginRQ>
</ns:AgentLogin>
i create soap client like this
$client = new \SoapClient("https://digicom-poc-ota.inspiretec.com/TravelinkCEService.svc?wsdl");
which is ok and then create soap call function like this
$data = array('AgentABTA'=>'DIGICOM_POC_DEMO'
,'UserName'=>'************'
,'Password'=>'************'
,'Products'=>'************'
);
$result = $client->__soapCall('AgentLogin',$data);
__soapcall give me error of empty request body.
Solution 1:[1]
Hope this might help you out:
$client = new \SoapClient("your_wsdl_link", [
'trace' => true
]);
$params = [
'AgentLoginRQ' => [
'DBName' => 'DATABASE_NAME',
'AgentABTA' => '****',
'UserName' => '****',
'Password' => '********',
'Products' => '',
]
];
$result = $client->YourFunction($params);
Solution 2:[2]
This is surely because of the array data structure which is incorrect according to the WSDL. You should definitively use a WSDL to php generator which is nowadays common. It helps structuring the request data and easily handle the response all with an OOP approach.
You should take a look to the PackageGenerator project which could really help you deal with this SOAP Web Service.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | emotality |
Solution 2 | Mikaƫl DELSOL |