$client = new SoapClient("http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL");
$result = $client->GetJobs();
It brings up all kinds of errors:
Quote:
Warning: SoapClient::SoapClient() [soapclient.soapclient]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\My Dropbox\compliance\tester2.php on line 4
Warning: SoapClient::SoapClient(http://sqlsvr1/RefrigerantCompliance.../Service1.WSDL) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\My Dropbox\compliance\tester2.php on line 4
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL" in C:\EDITED\EDITED\tester2.php on line 4
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL' : failed to load external entity "http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL" in C:\EDITED\tester2.php:4 Stack trace: #0 C:\EDITED\EDITED\tester2.php(4): SoapClient->SoapClient('http://sqlsvr1/...') #1 {main} thrown in C:\EDITED\tester2.php on line 4
What is going on here? I tried connecting to other public web services like amazon and it works without error.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
I have been given this web service, which I have been told will create an XML file once it is called through code, but I don't know how to get the XML from the web service in PHP.
This is what I have so far, but the second line returns an error and I don't think it's at all right...
PHP Code:
$client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl");
$result = $client->GetJobs(array());
My goal is to make a dynamic dropdown list that connects to another one of our servers using a web service.
How do I get this to return an XML file with the data that I can use to add to the drop down box?
If anyone would like to help, it would be much appreciated...
From what I've been reading and looking at a few examples I've gotten this so far, but it still throws errors:
PHP Code:
$client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl"); $result = $client->GetJobs(array('GetJobs')); //Error occurs on this line
// Note that $array contains the result of the traversed object structure $array = $result->GetJobsResult->JobDAO; print "Service Description:<select><option>Please Select One</option>"; foreach($array as $k=>$v){ print "<option>".($k+1).$v->RequestNo."</option>".$v->Description."</td></tr>"; } print "</select>";
Error:
Quote:
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in C:\xampp\htdocs\compliance\tester2.php:46
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://sqlsvr1/...', 'http://tempuri....', 1, 0)
#1 [internal function]: SoapClient->__call('GetJobs', Array)
#2 C:\xampp\htdocs\compliance\tester2.php(46): SoapClient->GetJobs('description')
#3 {main}
thrown in C:\xampp\htdocs\compliance\tester2.php on line 46
That looks like the wsdl file choking now. Same problem would be my guess, the http://sqlsvr1 cannot be resolved to a host. You can replace this with a domain or ip address though.
Technically, you do not need a wsdl in order to write web services. You just need to know what to expect.
Check out the __construct method of the SOAPClient class in the api, one of the examples should show you how to construct the service without a wsdl.
Best I can tell (and its been awhile since I've read wsdl files), the getJobs is a no parameter method, so you shouldn't need to provide it with any arguments. You'll need to get through the whole resolution problem first though.
Edit:
Mkay, so a little alteration from the above. The error message on an invalid domain is 'Could not connect to host'. When I have the correct host with an incorrect path to a soap server, the message is 'Not Found', same as you have. These are not triggered on construct as I expected, rather they are triggered on call.
So, it looks like all you need to do is ensure that the path to the file is correct from you're http root. The host is fine in this case with http://refrigerantcompliance, but the path from there appears to be invalid.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Yes, I thought that was the case as well, but I tried it on a server within our network and the WSDL showed up. I believe it can only be accessed within our firewall (which is fine since the service will only be run on our intranet).
If I were wanting to just display all the data in "description" from JobDAO would that be possible?
Yeah, but its been a long time myself since I did soap work, so you'll need to play around with you're results to see what datatypes and storage are in use. I'm thinking it should be a returned associative array.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
var_dump anything you need, it will give you an idea of the internal storage structure.
So if you make it past this:
PHP Code:
$result = $client->getJobs(); // Or $client->__soapCall('getJobs'); i believe is the technically 'correct' route
without triggering a soap fault, the problem is later in the handling. Dump the $result to see exactly what it is:
PHP Code:
var_dump($result);
It should tell you if its an object or string or array or whatever. My suspicion is it will be an array since there is no classmap on you're client indicating it should be an object.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
$client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl", array("trace" => 1)); $result = $client->__soapCall('getJobs');
echo "<pre>\n"; var_dump($result); echo "</pre>";
But there was an error...
Returns:
Quote:
Warning: SoapClient::__soapCall() expects at least 2 parameters, 1 given in C:\xampp\htdocs\compliance\tester2.php on line 44
Fatal error: SoapClient::__soapCall() [<a href='soapclient.--soapcall'>soapclient.--soapcall</a>]: Invalid parameters in C:\xampp\htdocs\compliance\tester2.php on line 44
So it's saying it needs two parameters, but I didn't believe that there were any parameters needed?
// with __call:
$soapClient->mynoparamfunc();
$soapClient->myparamedfunc('oneparam');
Although the __call approach is easier, its been deprecated in the api in favour of the __soapCall approach. I cannot tell you why they chose to do this.
On the plus side, you're above is looking good now, the errors are complaining about parameter conflictions, indicating that you're calls are now successful (though failing lol).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
I really do appreciate you helping me out with this, you've been amazing just with what you've helped me out with so far even if there are still errors. I've gotten further now than I have on my own.
I took what you wrote, assuming that the one I needed was the with 'mynoparamfunc' since my function has no parameters. I placed it within my code like so:
PHP Code:
$client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl"); $result = $client->__soapCall('GetJobs', array());
but now, I get a SoapFault Exception...
Quote:
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in C:\xampp\htdocs\compliance\tester2.php:47
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://sqlsvr1/...', 'http://tempuri....', 1, 0)
#1 [internal function]: SoapClient->__call('GetJobs', Array)
#2 C:\xampp\htdocs\compliance\tester2.php(47): SoapClient->GetJobs()
#3 {main}
thrown in C:\xampp\htdocs\compliance\tester2.php on line 47
Did I misunderstand the code or am I screwing something up?
Nope, this is the same error I was getting when I couldn't actually attach to a soapserver.
Instead of using the wsdl, try non-wsdl mode instead. To me, it appears that the Service1.wsdl file is pointing to the incorrect location for where the services are being served from (http://sqlsvr1/RefrigerantCompliance.../Service1.asmx). You can also try to type that manually into you're browser to see if you get a soap response.
Non-wsdl mode would be like so:
You'll need to play with the location, to me it appears that the path (RefrigerantComplianceService/Service1.asmx) is invalid for the service. I cannot help you with the correct path I'm afraid, but since its internal you should be able to either browse it or find out the correct location. If this location is correct, I'll need to think about this a little more.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
I may have messed you up, the address changed from sqlsrvr to refrigerantcompliance midway through this discussion. Sorry I didn't mention that...
But, the path seems correct:
I do believe that trying non-wsdl mode helped. It gave a different error as it said it did not recognize the value of the HTTP Header SOAPAction. Is that error due to the code or the address?
Fatal error: Uncaught SoapFault exception: [soap:Client] Server did not recognize the value of HTTP Header SOAPAction: http://tempuri.org/#GetJobs. in C:\xampp\htdocs\compliance\tester2.php:51
Stack trace:
#0 C:\xampp\htdocs\compliance\tester2.php(51): SoapClient->__soapCall('GetJobs', Array)
#1 {main}
thrown in C:\xampp\htdocs\compliance\tester2.php on line 51
That work? Looks to me like its the WSDL file causing the problems with incorrect targets.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php