2

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.

2 Answers 2

3

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);
Sign up to request clarification or add additional context in comments.

1 Comment

glad to know that this helped!
0

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.

6 Comments

thanks for your answer @mikael i installed the package which you mention but its give me error: "message": "Unable to parse at line 1 (near \"<AgencyLoginsRQ>\").", when i call this line of code $options = GeneratorOptions::instance('xml/test.xml'); and my test.xml file contain follwing code <AgencyLoginsRQ> <Authentication> <DBName>Test-Database</DBName> <IP>10.10.0.128</IP> </Authentication> <AgentABTA>12345</AgentABTA> <Password>12345</Password> </AgencyLoginsRQ> i want to send these parameters to __soapcall() function –
I think you misundertood the way to use the generator. The GeneratorOptions class is used to pass options to the generator, not an xml file. Did you generate the package yet? You don't have to call the __soapcall function, it is done implicitely when using the generated ServiceType* classes (if you generated the pakcage)
Can you please make a exmaple for me with correct formate which i can use actully i m new on it and i dont no how to use it this is my wsdl link below :: digicom-poc-ota.inspiretec.com/TravelinkCEService.svc?wsdl and this is my xml request with all parameters which i want to hit on the server
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope" > <soapenv:Header/> <soapenv:Body> <ns:AgentLogin> <ns:AgentLoginRQ> <ns:Authentication> <ns:DBName>DIGIcom</ns:DBName> <ns:IP>202.163.68.162</ns:IP> </ns:Authentication> <ns:AgentABTA>12345</ns:AgentABTA> <ns:UserName>user</ns:UserName> <ns:Password>test</ns:Password> </ns:AgentLoginRQ> </ns:AgentLogin> </soapenv:Body> </soapenv:Envelope>
Everything you need is explained at the usage section of the poject, github.com/WsdlToPhp/PackageGenerator#usage after having read the installation "process" github.com/WsdlToPhp/PackageGenerator#installation. Good luck.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.