soap not connecting in server PHP - php

Can anyone plz help
I have written a soap server and a client to test and it works in localhost and also in the server but when both are in save place but when I try to connect the localhost to the server it would not work. gives error
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\xampp\htdocs\PN Encryptor\service\client.php:9 Stack trace: #0 D:\xampp\htdocs\PN Encryptor\service\client.php(9): SoapClient->__soapCall('hello', Array) #1 {main} thrown in D:\xampp\htdocs\PN Encryptor\service\client.php on line 9
my code
///server
class EncSoapServer
{
public function hello($id){
return "Hello WOrld";
}
}
$options = ['uri' => 'http://prageethniranjan.epizy.com/service'];
$server = new SoapServer(null, $options);
$server->setClass('EncSoapServer');
$server->handle();
/// Client
$client = new SoapClient(null, array(
'location' => "http://prageethniranjan.epizy.com/service/encript.php",
'uri' => "http://prageethniranjan.epizy.com/service",
'trace' => 1 ));
//echo $return = $client->__soapCall("encrypt",array("4.1","this is a text message","Niranjan",1979,8,true));
try{
$responce = $client->__soapCall("hello",array('id'=>1));
echo $responce;
}
catch(SoapFault $e)
{
$response = $client->__getLastResponse();
echo $response;
$response = str_replace("&#x1A",'',$response); ///My Invalid Symbol
$response = str_ireplace(array('SOAP-ENV:','SOAP:'),'',$response);
$response = simplexml_load_string($response);
echo $response;
}
i try running on localhost it works
and put both script on server it also works
but could not connect it with server

Related

Returning Successful ping but after a fatal error

I am using the Solr library.And I have this code:
<?php
namespace Solarium;
use Solarium;
require 'vendor/autoload.php';
require(__DIR__.'\solarium\init.php');
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Client::VERSION . ' - ';
// create a client instance
$config = array(
'endpoint' => array(
'localhost' => array(
'host' => 'localhost',
'port' => 3306,
'path' => '/solarium/',
)
)
);
$client = new Solarium\Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try {
$result = $client->ping($ping);
echo 'Ping query successful';
echo '<br/><pre>';
var_dump($result->getData());
echo '</pre>';
} catch (Solarium\Exception $e) {
echo 'Ping query failed';
}
htmlFooter();
Well.It sorta works.
It gives me this:
Solarium library version: 3.0.0 - Ping query successful
Fatal error: Uncaught Solarium\Exception\UnexpectedValueException: Solr JSON response could not be decoded in C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\vendor\solarium\solarium\library\Solarium\Core\Query\Result\Result.php:158
Stack trace:
#0 C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\ping4.php(34): Solarium\Core\Query\Result\Result->getData()
#1 {main}
thrown in C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\vendor\solarium\solarium\library\Solarium\Core\Query\Result\Result.php on line 158
So The ping was successful.but I get a fatal error after a successful ping.
What am I supposed to get? And what am i doing wrong?
Please help.

php soap client issue

I have to develop a php client which connects to a soap webservice server.
With SoapUI, I can test the webservice which is working fine.
But from my php client, I get the following error:
syntax error near << from >>
Here is my php client code:
$wsdl = 'http://intrageo.cannes.fr:81/AdresseRecherche/searchByWhereClause?wsdl';
$trace = true;
$exceptions = false;
$xml_array['context'] = '?';
$xml_array['table'] = 'adr_digadr';
$xml_array['colonneARecuperer'] = 'numero';
$xml_array['clauseWere'] = 'nomvoie= \'BOULEVARD COINTET\'';
$xml_array['nbMaxLignes'] = 10;
try {
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->getDistinctValue($xml_array);
} catch (Exception $e) {
echo "Error!";
echo $e->getMessage();
echo 'Last response: '. $client->__getLastResponse();
}
var_dump($response);
Thanks for help.
It works if I use $response=$client->_soapCall("getDistinctValue",$xml_array); instead of $response=$client->getDistinctValue($xml_array)

Getting could not connect to host error when using soap

I am using SOAP to call a web servicefrom a Linux Centos 6 server and a php client. In this week I have been getting could not connect to host error from soapCall method. My code is as below and I have not changed it at all for some months but recently it gets this error most of the time. I have read most answers to related questions here but my problem have not been solved.
$wsdl="http://x.x.x.x:x/gw/services/Service?wsdl";
//Set key as HTTP Header
$aHTTP['http']['header'] = "key:" .$key ."\r\n";
$context = stream_context_create($aHTTP);
try
{
$client = new SoapClient($wsdl,array("soap_version" => SOAP_1_2,'trace' => 1,"stream_context" => $context));
}
catch(Exception $e)
{
return "something";
}
//I make $parametrs
try
{
$res = $client->__soapCall("send",array($parametrs));
}
catch(Exception $e)
{
print_r($e->getMessage()); //Most of the time it prints could not connect to host
}
I changed SOAP from _1_1 to _1_2 but nothing changed.
This is how I call SOAP webservice, please note Service?wsdl should be Service.wsdl
Example
//Initialize values
$wsdl = "Service.wsdl";
$url = "http://x.x.x.x:x/gw/services/";
$username = "********"; //add username
$password = "********"; //add password
$client = new SoapClient("$url".$wsdl);
$params = array(
"username"=>$username,
"password"=>$password
);
$response = $client->UserLogIn($params); //UserLogIn is the function name
var_dump($response); // to see webservice response

First time fatal error lost

Hello? Is anybody in there?
I've used this before years ago now I'm back. First time gives me this:
Fatal error: Uncaught Services_Twilio_TinyHttpException in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php:119 Stack trace: #0 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio.php(178): Services_Twilio_TinyHttp->__call('post', Array) #1 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array) #2 /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/Rest/Calls.php(32): Services_Twilio_ListResource->_create(Array) #3 /home/www/skyphilly6.com/twill/index.php(9): Services_Twilio_Rest_Calls->create('8052629166', '8058130331', 'htttttp://demo.twi...') #4 {main} thrown in /home/www/skyphilly6.com/twill/twilio-php/Services/Twilio/TinyHttp.php on line 119
Here's my short code tried many additional lines same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'washere';
$client = new Services_Twilio($account_sid, $auth_token, $version);
$client->account->calls- >create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
?>
Also tried uncommenting this same result:
<?php
require('./twilio-php/Services/Twilio.php');
$version = "2010-04-01";
//$account_sid = 'SK5b9d2d022b971335e17ee50c813ae231'; $auth_token = 'was';
$account_sid = 'ACcfc1ba0d12c58180319486144bef540e'; $auth_token = 'was';
$client = new Services_Twilio($account_sid, $auth_token, $version);
//try {
//$call=
$client->account->calls->create('8052629166','8058133333','htttttp://demo.twilio.com/welcome/voice/');
//,array(
//'Method' => 'GET',
//'FallbackMethod' => 'GET',
//'StatusCallbackMethod' => 'GET',
//'Record' => 'false', ));
//echo 'Started call: ' . $call->sid;
//} catch (Exception $e) { echo 'Error: ' . $e->getMessage(); }
?>
Please point me in the right direction.
Added:
$http = new Services_Twilio_TinyHttp('https://api.twilio.com',
array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
))
);
//$client = new Services_Twilio($sid, $token, "2010-04-01", $http);
$client = new Services_Twilio($account_sid, $auth_token, $version,$http);
Noticed it doesn't matter what I use for my token same error
Can't find the error log:
$client->http->debug = true;
Hello?

php with soap service

i need to use this xml file:
http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL
to connect to GetTopGainers methode
i use this code:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.mubashermisr.com/Mubadelayed/Service1.asmx?WSDL";
$parameters = array("Username"=>"xxxx","Password"=>"xxxx","ID"=>"xxxxx");
$client = new SoapClient($wsdl_path, array('trace' => 1));
try {
$result = $client->GetTopGainers($parameters);
print_r($result);
}
catch (SoapFault $exception) {
echo $exception;
}
?>
But i get the following error:
SoapFault exception: [soap:Server] Server was unable to process request.
---> Object reference not set to an instance of an object. in
C:\wamp\www\soap\soap.php:24 Stack trace: #0
C:\wamp\www\soap\soap.php(24): SoapClient->__call('GetTopGainers', Array)
#1 C:\wamp\www\soap\soap.php(24): SoapClient->GetTopGainers(Array) #2
{main}
Any help will be appreciated.
Thanks
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "URL";
$parameters = array("Username"=>"xxx","Password"=>"xxx","ID"=>"xxx");
$header = new SOAPHeader('Namespace', 'Auth', $parameters);
$client = new SoapClient($wsdl_path);
$client->__setSoapHeaders($header);
try {
$topGainers = $client->GetTopGainers(); // Top Gainers
echo"<pre>";
print_r($topGainers);
echo"</pre>";
}
catch (SoapFault $exception) {
echo $exception;
}
?>

Categories