atifzaman
atifzaman

Reputation: 23

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.

Upvotes: 2

Views: 6216

Answers (2)

Abdul Mannan
Abdul Mannan

Reputation: 70

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

Upvotes: 3

Mika&#235;l DELSOL
Mika&#235;l DELSOL

Reputation: 760

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.

Upvotes: 0

Related Questions