PHP SOAP WSDL How to call soap action with the same method name


PHP SOAP WSDL How to call soap action with the same method name



I have WSDL which returns me function list which is included below


[0] => ExternalCacheAccessRsp service(ExternalCacheAccessReq $parameters)
[1] => PingRsp service(PingReq $parameters)
[2] => SystemInfoRsp service(SystemInfoReq $parameters)
[3] => TimeRsp service(TimeReq $parameters)



How I can call PingReq function by



__soapCall()



When I am trying to call __soapCall('service') it returns me first method



"ExternalCacheAccessReq"





If you want to use __soapCall, the first parameter of the function is the service function, the second is service parameters. You can call it like $client->__soapCall('PingReq', $parameters).
– Cristian Bitoi
Oct 14 '13 at 14:28


$client->__soapCall('PingReq', $parameters)





Also look at another way to call service functions (below is my answer).
– Cristian Bitoi
Oct 14 '13 at 14:29





@CristianBitoi Unfortunately this solution is incorrect. I have message italic Function ("PingReq") is not a valid method for this service italic
– skyner87
Oct 15 '13 at 8:05





4 Answers
4



Thank you for your answer but both solutions are incorrect for this case.



In the first case Soap returns that I didn't pass attribute "CacheName" which is obligatory for "ExternalCacheAccessRsp" (first method).



In the second solution I have message that method "PingRsp" is not valid. The valid method is "service", but as you see on the top all methods have name "service".



The only way to do this is writing the XML request manually and sending by the method SoapClient::__doRequest.


SoapClient::__doRequest



Take a look at my answer here: stackoverflow.com/a/51099774/6783224



Given a SoapClient like:


$serviceUrl = 'your service address';

$client = new SoapClient($serviceUrl, array(
'trace' => true,
'soap_version' => SOAP_1_2,
'encoding' => 'UTF-8')
);



You can call your method like:


$client->PingRsp($parameters);



Best regards!



Your web service method is overloaded and so you should set the input parameters as specified by PingReq. The only way the server can distinguish between which overload you want is by the format and structure of the input parameters. You can examine the WSDL to see what the structure of PingReq is.


PingReq


PingReq


$client = new SoapClient('http://wsdl'); // <-- enter your wsdl url

// set $params as defined by your WSDL for the `PingReq` structure.
$params = array(
'param1' => 'one',
'param2' => 'two'
);

$response = $client->service($params);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV