chombium Posted June 5, 2007 Share Posted June 5, 2007 Hi, I'm developing a soap server/client using PHP. When I was testing the application locally (the server and the client were running on the same machine) everything worked great. Now I'm trying to run the client from another machine, to check if accessing the service from a remote location will work, and I hit the wall The code for the client is: <?php ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache $client = new SoapClient("http://testsv/soapserver/msg_api.wsdl"); $sessionID = $client->login("user","pass","1234567"); print_r("SessionID: ".$sessionID."<br>"); if ($sessionID > 0){ try{ $sms = $client->postMessage($sessionID,"jim", ""); print_r("Message1: ".$sms."<br>"); } catch(Exception $e){ echo $e->getMessage(); } $bye = $client->logout($sessionID); print_r("Logout: ".$bye."<br>"); } ?> The client connects to the server, tries to login and if it logs in it calls the function postMessage. The server and the .wsdl file hold the business logic, just some MySQL functions, nothing special When I'm trying to access the service from a client that works on a different machine than the server, the script crashes when the funciton login is called. I tested the service with a c++ client as well and got the same error So I realized that it's an error on the server side The error that I got when testing wtih the php client is: SoapFault exception: [HTTP] Not Found in C:\Program Files\Apache Software Foundation\Apac he2.2\htdocs\soapserver\client.php:8 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', '', 1, 0 ) #1 [internal function]: SoapClient->__call('login', Array) #2 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\soapserver\client.php(8 The server environment is SLES 10, mysql 5.0, apache 2.2 and php 5.2.1 Is there something that should be configured (Apache and/or PHP) so that the service will be visible form machines other than the one the server is running? ??? ??? ??? I'm really stuck, I've even checked the soap code to trace the error message but didn't find anything Link to comment https://forums.phpfreaks.com/topic/54268-soapfault-exception-http-not-found/ Share on other sites More sharing options...
chombium Posted June 6, 2007 Author Share Posted June 6, 2007 After a bit more testing and hitting my head in the wall I solved the problem The problem was in specifying url when creating the client and server, and defining the SOAP:address location in the .wsdl file. The client had the url visible by the outside world: $client = new SoapClient("http://testsv/soapserver/msg_api.wsdl"); But the server and the wsdl definition had localhost in the url api_server.php $server = new SoapServer("http://localhost/soapserver/msg_api.wsdl"); msg_api.wsdl <service name="msg_api"> <documentation>gSOAP 2.6.0 generated service definition</documentation> <port name="msg_api" binding="tns:msg_api"> <SOAP:address location="http://localhost/soapserver/api_server.php"/> </port> </service> The problem was that client connnected to the server machine, and when the soap server was created it crashed due to the "invalid" url. Actually, I thought that i can use localhost in the url because, the server code and the wsdl were on the same machine, but I was wrong. Always specify the "outside world" url wherever its needed I changed the url-s to: $server = new SoapServer("http://testsv/soapserver/msg_api.wsdl"); and <service name="msg_api"> <documentation>gSOAP 2.6.0 generated service definition</documentation> <port name="msg_api" binding="tns:msg_api"> <SOAP:address location="http://testsv/soapserver/api_server.php"/> </port> </service> respectively and everything works well now Link to comment https://forums.phpfreaks.com/topic/54268-soapfault-exception-http-not-found/#findComment-269044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.