PHP - Php Soapclient::__soapcall() Connection Issue
Hey, 'all. I think I'm just tired because I can't see the issue here, but I'm trying to run a SOAP 1.2 call to a legit endpoint using a legit function call and getting nothing but a 'Could not connect to host' message with a fault code of 'HTTP'. Here's some code: class Testing{ private $_user = "username"; private $_pass = "password"; private $_system = 1; private $_uri = "http://legit.com/endpoint/"; private $_location = "givenlocation.asmx"; private $_soapClient; public function __construct(){ $this->_soapClient = new SoapClient(null, [ 'location' => "{$this->_uri}{$this->_location}", 'uri' => $this->_uri, 'soap_version' => SOAP_1_2, 'exceptions' => true, 'trace' => true, ]); } public function makeCall(){ try{ $data = $this->_soapClient->__soapCall('functionCall', [ 'username' => $this->_user, 'password' => $this->_pass, ]); }catch(SoapFault $e){ die("<pre>".var_export($e, true)."</pre>"); } } } $testSoap = new Testing(); $testSoap->makeCall(); I'll happily take a "Let me Google that for you" result link if it's that simple, but I'm just not seeing the problem. Anybody? As always, help is greatly appreciated.
Forgot to mention - I don't get an error on instantiation of the SoapClient() object, just the __soapCall() call. Edited June 18, 2019 by maxxdSimilar TutorialsHi y'all. I've been looking at this for two days now and my head is starting to hurt from it.
I'm trying to integrate with an existing web service for client log-in and having trouble getting it done and Google is being very little help at this point. Here's the code, annotated where necessary:
namespace myNamespace; MyClass{ private $_apiLoginAddr = 'http://xxx.xxx.xxx.xxx:xxxx/ServiceAddress/Login.asmx?wsdl'; public function logIn($email,$id){ /* // these work... $testClient = new \SoapClient('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClient->ConversionRate(array('FromCurrency'=>'USD','ToCurrency'=>'CAD')); print($resp->ConversionRateResult); $testClientAWS = new \SoapClient('http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClientAWS->ItemLookup(array('ItemID'=>'1430260319')); var_dump($resp); $testClientP = new \SoapClient('https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl',array('trace'=>1,'execptions'=>1)); print_r($testClientP->__getFunctions()); die(); */ // turning off caching because apparently it's sometimes an issue... ini_set('soap.wsdl_cache_enbled','0'); ini_set('soap.wsdl_cache_ttl','0'); // this doesn't work even a little bit... try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient($this->_apiLoginAddr,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); var_dump($client->__getLastRequest()); print('break'); var_dump($client->__getLastResponse()); }catch(\SoapFault $e){ print('Exception thrown!'); var_dump($e); die(); } print('Succesfully completed call!'); var_dump($results); die(); } }Using this code, the browser churns for about a minute before I get the error "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxx.xxx.x...ceAddress/Login.asmx' : failed to load external entity "http://xxx.xxx.xxx.x...ess/Login.asmx", with or without the call to WebsiteLogin(). Now, I've also tried a non-wsdl version where I replaced the credentials array and SoapClient instantiation with the following: try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'location' => $this->_apiLoginAddr, 'uri' => 'http://tempuri.org', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient(null,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); /* see previous code block */Using this approach, my browser again churns for about a minute before I get the error "Could not connect to host". If I don't actually try to log in using the service's WebsiteLogin() function, SoapClient doesn't throw an error on this one and reports a successfully completed call. Which does me no good at all, because my users can't log in if I don't call the WebsiteLogin() function. I can visit the end-point directly in my browser and it's definitely there and active, and SoapUI has no problem at all with the request or the response. I've tried uncommenting the open_ssl.dll in my php.ini, turning the wsdl caching options off in the php.ini directly, and pretty much everything short of ritual sacrifice to no avail. My log in form is sending the credentials via AJAX to the logIn() method above, and all this is happening in a WordPress site. However, as the webservicex, webservices.amazon.com, and pilot.prove-uru.co.uk soap calls all complete successfully, I don't think that's an issue. I've spoken with the maintainer of the service gateway and he swears we're not blacklisted through the firewall, but nothing is working. Anybody come across anything similar? Or have better Google skills that can actually find an applicable answer? Or have any ideas at all? 'Cause I'm at a loss... This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=317047.0 I'm using XAMPP and im a major noob. Last nite I was following this tutor and the connection script that was on it didnt work for me. So today I tried a connection script from another tutor on another site that worked just fine. here is the script that worked I saved it as test.php and went to localhost/test/php and it loaded a page connected to mysql <?php mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> The script that didnt work i saved it as connect.php and went to localhost/connect/php and it gave me a page saying "Object not found error "the request url was not found on this server." I understand this script doesnt have a echo on it but shouldnt it still take me to a blank white page instead of a error page. Or is there something wrong with it. Really appreciate any help with this. the script that didnt work is below <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysq1_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); ?> Any charitable soul who can help me? I've been having this problem for days and I can't solve it. I would be forever grateful if anyone could help I already checked in phpinfo ()and the class soap client is enabled
the request that I 'm making is on another domain with port 81 (this domain has my ip on the withlisted) and on my domain I use security certificate. Is it around? anyway wsdl is he
$client = new SoapClient('https://dekrainspecoes.pt/acp/PROD_CustomUI_ACP_Member_Validation_WS.WSDL'); if (!empty($result->QueryByNumCartao_Output->Cartao_Ativo)) { echo 'The userId : '.$result->QueryByNumCartao_Output ->Pessoa_ID; } $JSON = json_encode($result); Hey, I've got a REALLY complicated issue. I'll do my best to explain it. I have a 3rd party API (soap) that I'm trying to integrate, I'd like to use namespaces to keep their objects/classes separate from ours. In a nut shell what is happening is that I have a soap struct which maps down to a php object (Transaction) inside that object are more objects. as i build out the parameter array to pass to soapCall everything looks good. however the xml that gets generated by soapCall is missing the transaction value, the tag is their <transaction/> but no value. Now, I assumed this is due to namespacing ruining the automated object detection in the soap client. SO i did: $auth->transaction = new \soapVar($bank_trans, XSD_ANYTYPE, "Transaction" , "http://masked/Transactions"); this gets the value into the xml however now i get a really weird error soapFault: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://masked/Transactions:transaction. The InnerException message was 'Error in line 2 position 4965. Element 'http://masked/Transactions:transaction' contains data of the 'http://masked/Transactions:Transaction' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Transaction' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details. in /home/jvieira/dev/www/trunk/include/CWS/CWSBankcard.php on line 1001 Call Stack #TimeMemoryFunctionLocation 10.0061930576{main}( )../TransactionManagement.php:0 20.00822682296CWS\CWSClient->authorize( )../TransactionManagement.php:156 30.00832695680CWS\CWSBankcard->Authorize( )../CWSClient.php:418 40.00832696736SoapClient->__soapCall( )../CWSBankcard.php:1001 ) ) any ideas? Thanks, Joe Hi,
Well, I'm having this
The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetSomething'. End element 'Body' from namespace 'http://schemas.xmlso.../soap/envelope/' expected. Found element 'param1' from namespace ''.
The soapclient request itself is something with multiple namespaces, like :
<aaa xmlns="namespace1"> <bbb xmlns="namespace2" xmlns:i="http://www.w3.org/20...hema-instance"> <requestparams>xxxxx</requestparams> </bbb> </aaa> So far I think this may got to do with multiple namespaces, so I've been trying to figure out how to deal with this for hours to no avail. Anyone can shed a light into this problem ? Thanks in advance, Hi All, I have a landing page that I use, but often my sql database is too busy or gets overwhelmed and then the landing page just stalls and traffic is lost. Here it is: Code: [Select] <?php //ini_set("display_errors",1); if(!$src) $src = $q; define("__EXEC_", 1); include("config.php"); include("custom.php"); function lsp_visit_find($__val, &$__uid) { global $u; global $db; $l_campaign = array("campaign_id"=>"", "url"=>"", "cost"=>"0.00", "name"=>"-", "ad_keyword"=>"", "mapped_keyword"=>""); $l_visit = array(); $q = $_GET['q']; $src = $_GET['src']; // for STAGE #1 (visit definition): get cost, ad keyword, mapped keyword. $l_campaign['name'] = "info"; $l_campaign['mapped_keyword'] = "$q"; $l_campaign['ad_keyword'] = "$src"; $l_campaign['cost'] = ".02"; // get referer (campaign URL). if no campaign found, - create it! if (!empty($l_campaign['name'])) { $r = mysql_query("select campaign_id,name from campaign where name='$l_campaign[name]'"); if (!mysql_affected_rows($db)) { $r = mysql_query("insert into campaign(name,cost, creation_date,last_update_date) values('$l_campaign[name]',$l_campaign[cost], unix_timestamp(),unix_timestamp())"); $l_campaign['campaign_id'] = mysql_insert_id($db); } else { $w = mysql_fetch_assoc($r); $l_campaign = array_merge($l_campaign,$w); } } // check, whether we had visits from this IP for this keywords within 2 minutes. // if we have one, get its ID, otherwise - create new! $visit_id=""; if (!empty($l_campaign['ad_keyword']) && !empty($l_campaign['mapped_keyword']) ) { $ip = get_real_ip(); $r = mysql_query("select visit_id,uid,campaign_id,ad_keyword,mapped_keyword from visit where ip='$ip' and ad_keyword='$l_campaign[ad_keyword]' and mapped_keyword='$l_campaign[mapped_keyword]' and currtime>=from_unixtime(".(time()-120).") limit 1"); if (!mysql_affected_rows()) { $__uid = md5($ip.time().$l_campaign['campaign_id']); $x = mysql_query("insert into visit(ip,uid,cost,currtime,campaign_id,ad_keyword,mapped_keyword) values('$ip','$__uid',$l_campaign[cost],now(),$l_campaign[campaign_id],'$l_campaign[ad_keyword]','$l_campaign[mapped_keyword]')"); $visit_id = mysql_insert_id($db); } else { $l_visit = mysql_fetch_assoc($r); $visit_id = $l_visit['visit_id']; $__uid = $l_visit['uid']; } return $visit_id; } } $db = mysql_connect(__CFG_HOSTNAME, __CFG_USERNAME, __CFG_PASSWORD); mysql_select_db(__CFG_DATABASE, $db); $u = isset($_GET['u'])? $_GET['u'] : 2; $uid = ""; $visit_id = lsp_visit_find($_REQUEST['l'], $uid); if (!empty($visit_id)) { setcookie("x_uid", base64_encode($visit_id."QQ".$uid), time() + 3600); } global $q; mysql_close($db); $q = $_GET['q']; $src = $_GET['src']; header("Location: http://www.mydomain.com/search/?q=$q"); exit(); ?> My question is how do I code it so that if after 5 seconds or so, or the connection can't be made, it just terminates the connection and auto loads the header redirect at the bottom of the page? Thanks! Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 10 Hallo I am beginner and starting to learn php I got this message when I want to connect with server. Can I get some suggestion what to do? Thanks Hi! I got the following problem... I have a SQL 2005 Server in a VPN. For security reasons,internet access to the database server is only possible for VPN members. Now i want to connect to the openvpn Server from my webserver in order to connect to the database for some webreports. How can i achieve this using php? thanks HI fellow programmers, Can i connect a textbox to a field in the MySql using the id of the text box? If yes, can u show me a small example. Thanks RAM Hi Guys, need a little help and drawn a blank. The code that is not working is below $result = $conn->query("SELECT * FROM MK_migration_details WHERE mig_bid='".$_SESSION['bid']."'"); I can confirm the $_SESSION['bid'] is working as echo's out on another part of the page. and the above $result works when i manually type the search criteria like below. $result = $conn->query("SELECT * FROM MK_migration_details WHERE mig_bid='300101'"); Basically no result turn up on the page. Any ideas or advise how I can diagnose? I have an app that connects to a source safe server to perform a command via shell_exec(). I had used exec(), but shell_exec seems to work better since I am on Linux. The command connects to the server and tells it to promote a file to the next level. On Windows this ran without a hitch, but on Linux I gat an error that reads: Quote Socket error when reading request from [172.20.22.1]: 3537808 ; Socket closed. I am told that the reason for this error is that PHP broke the connection to the server before the server completed the job and was able to shutdown properly. The only way I have found around this is to place a sleep(3) to the script. This is really not ideal since that means that there is at least 3 seconds between each command, which can really extend the time it takes to perform if there are numerous files. If PHP breaks the connection before the program can close it will leave the program open and PHP cannot perform any more commands to the server since it is stuck on the last command. If too many are given the machine will lock up due to resources being eaten up. I'm wanting to know if there is a way to tell PHP to not let go of a connection so quickly. I tried "nohup", but that does not help. I am new to Linux and am at a loss of what my options are beyond the sleep() method. I really feel that there has to be a better way or setting that can be manipulated to fix this issue altogether. Thanks in advance for any help. Cy On some occasions I need to connect to a second and third database in the same script (maybe 5% of scripts have at least a second connection). Usually I would just select the new database. However, my host requires different users to be created for each database. What is the best way to do this? Close current connection (say db1) and open new (say db2) OR keep all open, creating 2nd and 3rd connections. I am happy with the design of my database, and don't want to merge all these tables into one db. Overall I am still happy with my host, so I'd rather not change. hi everyone I have a question... does creating a connection to mysql takes time depeding on the database size? Lets say that in my entire project I will be connection to 4 databases so I created a config.php which looks like this: Code: [Select] $hostname = "localhost"; $username = "root"; $pword = ""; $con1 = @mysql_connect($hostname,$username,$pword,true); @mysql_selectdb("databasename1",$con1); $con2 = @mysql_connect($hostname,$username,$pword,true); @mysql_selectdb("databasename2",$con2); $con3 = @mysql_connect($hostname,$username,$pword,true); @mysql_selectdb("databasename3",$con3); $con4 = @mysql_connect($hostname,$username,$pword,true); @mysql_selectdb("databasename4",$con4); so, this file is included in every pages, I put this on the top. Basically every page request it will open 4 connection and the script will only use 2 connection and another page will only 1 and so on..... this style is very convenient as for I am not creating a connection in every page.. But my concern is will it effect the performance of my system? Tnx in advance..... It seems that a class can't inherit an object as attribute? I'm trying to make my UpperNavigation class access the $this -> db attribute which is a mysqli connection. Is this possible? If not, how do I manage my connection in other classes? Code: [Select] class Connection{ public $state = false; public $db; public $db_table_names; function __construct($name){ include('dbconfig.php'); $this -> db = new mysqli($dbconfig[$name]['server'], $dbconfig[$name]['username'], $dbconfig[$name]['password'], $dbconfig[$name]['database']); $this -> state = true; $this -> db_table_names = $db_table_names; $this -> db -> query("SET NAMES 'UTF8'"); } function close(){ if($this -> state == true){ $this -> state = false; $this -> db -> close(); unset($this -> db); } } } This is my attempt of accessing Connection::$db connection. Code: [Select] class UpperNavigation extends Connection{ public $all_parents_sorted; public function printUpperNavigation(){ echo '<a href=\''.$this -> current_page.'\'>'.$this -> title . '</a>'; } public function printSearchBar(){ echo '<input type=\'text\' value=\'Search by name...\' onfocus="if(this.value == \'Search by name...\'){this.value = \'\';}" onblur="if(this.value == \'\'){this.value = \'Search by name...\';}"/>'; } public function fetchAllParents($sp_id){ $latest_id = $sp_id; if(isset($this -> db)){ echo 'yes'; }else{ echo 'no'; } $query = 'SELECT default_name, type, sp_id FROM ' . $this -> db_table_names['sport'] . ' WHERE sp_id = "' . $sp_id . '"'; $result = $this -> db -> query($query); // THIS IS THE PROBLEM } } I was not expecting this but when I managed to connect to a chatroom and close out firefox.... The user stayed in the chatroom. This user should of pinged out by now but it's staying online. How do I end this connection? So far I turned off my internet, and blocked all access to the site. Hello, Does anyone know how may i detect the Connection type by user IP? Broadband etc. I am trying to learn PHP on my own through examining existing code that I have. It's code written for a database. The web app allows the user to login and interrogate the system for and extract information onto a utility bill. I noticed this nice bit of informational code at the top.... if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } I would expect the output would be "Connection established".or "Connection could not be established". but it reads this. "Connection established. You are currently logged in as" 123456 No where in the code is there a statement that includes "You are currently logged in as". Maybe I'm overlooking something. thanks for any help. I can not send the code because I do not have permission. Any help would be greatly appreciated. Hi all! I'm trying to retreive my own status updates from LinkedIn, but without success uptill now. I did setup an oAuth communication which resulted in requesting the user for permission for the application to access his profile and I retrieved an access token succefully which I saved in the database. However, when I try the following after that, using the access token: Code: [Select] $options = array( 'consumerKey' => '[key here]', 'consumerSecret' => '[secret here]', ); // This is where I get the token, not really interesting :p $dbSocialAccount = new SocialAccount(); $oSocialAccount = $dbSocialAccount->fetchRow('id = "3"'); $token = unserialize($oSocialAccount->token); $client = $token->getHttpClient($options); $client->setUri('https://api.linkedin.com/v1/people/~'); $client->setMethod(Zend_Http_Client::GET); $response = $client->request(); $content = $response->getBody(); echo 'content:<br /><br />'; echo $content; exit(); It works fine! I get some profile information of the user/my own linkedin account. Now I want to retrieve the last, say 5, updates from my own account, so I change the request URL to: http://api.linkedin.com/v1/people/~/network/updates?scope=self Which should get me all my own updates... however now I get an error: 401 1303487627487 0 [unauthorized] I don't understand why I'm not authorized now? I do have access I guess, when the first example works? What am I doing wrong here? Thank you for your answer! If you need more information, please ask! I'm writing a quick little script to grab some information from Stickam.com, specifically using the "API" they have set up to get a user id from a provided username, and a username from a provided userid. These are both publically accessible pieces of information, so I'm not getting into anything I shouldn't, I'm just using the publically accessible API instead of scraping the HTML. For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code: Code: [Select] $username = @$_GET['username']; if(!$username) { die("no username"); } $url = "http://www.stickam.com/servlet/ajax/getLiveUser?uname=".$username; $html = file_get_contents($url, false, $context); echo "<pre>"; echo $html; echo "</pre>"; But everytime I load this page on my server, I get this response: Warning: file_get_contents(http://www.stickam.com/servlet/ajax/getLiveUser?uname=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7 I can load it just fine on my Apache server running on my personal computer, and in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_contents() call, but so far nothing seems to work. Any ideas? |