So, I'll just come right out and say I an fairly new to SOAP.
I've done PHP for quite some time, and XML, but never actually made anything with WSDL and SOAP. So here's goes (hopefully this isnt too stupid).
I have a WSDL file I want to request something from. Ex: http://whateverservice.org/?wsdl
And I want to do a simple API call for a job called "JobAPI_CheckConnection". Using SoapUI, this is the SOAP code I get when looking at that job:
<soapenv:Envelope xmlns:soapenv="http://schemas/xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:JobAPI_CheckConnection/>
</soapenv:Body>
</soapenv:Envelope>
So, how would I translate that into PHP? From looking at this tutorial: http://devzone.zend.com/2202/php-and-soap-first-steps/
I get some of it, but not all... From what I can gather so far, my PHP code should look somewhat similar to this:
<?php
$wsdl = "http://whateverservice.org/?wsdl";
$client = new SoapClient($wsdl);
$result = $client->JobAPI_CheckConnection();
echo $result->JobAPI_CheckConnectionResult;
?>
But this returns nothing, and the site fails to load. In other words, something is obviously wrong. In the tutorials I have seen so far, you send a request as well as a paramter to get a response, but this one, you just have to call on that job, and I would somewhat expect a result from that, but I have no clue how...
Anyone that either would be so willing as to point me in the right direction a tutorial or similar. Or if anyone would just come right out and give me the answer, that's cool, I just hope I can learn from it.
Sidenote: I am also not sure if I need to log in on the service I am connecting too, but if so, I honestly have next to no clue how... I assume it would be an array or parameter added to the "newSoapClient" call, but how and where, I dont know...
Thanks for taking care of a noobie!
First, you should look to the native PHP SoapClient class .
Then if you like using PHP objects and structured programming, I would advise you to use a WSDL to php generator that eases the way you create a request and receive the response. To do so, take a look to the WsdlToPhp project that you can use online at https://www.wsdltophp.com
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.