PHP SOAP Client is not working - php

I never developed a SOAP client, and now I have to do it and am having difficulties. This are the input parameters I have to send to the method "Agregar":
<Clientes>
<Cliente>
<Rut>123456785</Rut>
<Nombre>123456785</Nombre>
</Cliente>
</Clientes>
this is the testing code for the client I have done yet:
<?php
class Socio {
function Socio($rut, $nombre)
{
$this->nombre = $nombre;
$this->rut = $rut;
}
}
$client = new SoapClient("theurl...");
$socio = new Socio(156371777, "Sebastian");
$params = array(
"Cliente" => $socio,
);
$response = $client->__soapCall("Agregar", $params);
var_dump($response);
but it is not working... I get the following error:
Fatal error: Uncaught SoapFault exception: [soap:Server] The server can't process the request. ---> The value cannot be null. Parameter name: s in /var/www/friends/awto/intouch/ccinterface.php:22 Stack trace: #0 /var/www/friends/awto/intouch/ccinterface.php(22): SoapClient->__soapCall('Agregar', Array) #1 {main} thrown in /var/www/friends/awto/intouch/ccinterface.php on line 22

Related

Uncaught SoapFault exception: [soap:Server] Server was unable to process request

i use this PHP Code :
<?php
ini_set("soap.wsdl_cache_enabled", "0");
$AccountShabaCode = "123456789012345678900000";
$WorkTitle = "Example";
$GuildCode = "48160000";
$PardakhtYarTitle = "Xxxa";
$soapclient = new SoapClient('http://87.107.134.111:8021/PardakhtYar.asmx?wsdl');
$add_new_request = $soapclient->AddNewRequest(array('AccountShabaCode' => $AccountShabaCode, 'Password' => $Password, 'WorkTitle' => $WorkTitle, 'GuildCode' => $GuildCode, 'PardakhtYarTitle' => $PardakhtYarTitle));
print_r($add_new_request);
?>
and get this error :
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\WAMP\home\example.tld\public_html\test.php:11
Stack trace:
#0 C:\WAMP\home\example.tld\public_html\test.php(11): SoapClient->__call('AddNewRequest', Array)
#1 {main}
thrown in C:\WAMP\home\example.tld\public_html\test.php on line 11
How can I fix this error?
i need call "AddNewRequest" ( http://87.107.134.111:8021/PardakhtYar.asmx?op=AddNewRequest )

How to set up SOAP client and server using php

i have some problems with the soap client and soap server.
server.php on server side
class Server {
public function hello($someone) {
return "Hello ". $someone;
}
}
$options= array('uri'=>'http://localhost/');
$server=new SoapServer(NULL, $options);
$server->setClass('Server');
$server->handle();
index.php on client side
<?php
$options = array('location' => 'http://localhost/server.php',
'uri' =>'http://localhost/');
$client = new SoapClient(NULL, $options);
echo $client->hello('Greg');
I'm testing this local on xampp and get the Error:
What do i make wrong ? Can i test it localy or do i have to set up a server for this. If yes, is it possible to run this on IIS ?
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in
C:\xampp\htdocs\SOAP\index.php:8 Stack trace: #0 [internal function]:
SoapClient->__doRequest('http://localhos...',
'http://localhos...', 1, 0) #1 C:\xampp\htdocs\SOAP\index.php(8):
SoapClient->__call('hello', Array) #2
C:\xampp\htdocs\SOAP\index.php(8): SoapClient->hello('Greg') #3 {main}
thrown in C:\xampp\htdocs\SOAP\index.php on line 8

PHP Error SoapClient getProxy()

Getting this error while using soap service php :
Fatal error: Uncaught SoapFault exception: [Client] Function ("getProxy") is not a valid method for this service in C:\webserver\www\feeder\index.php:7 Stack trace: #0 C:\webserver\www\feeder\index.php(7): SoapClient->__call('getProxy', Array) #1 C:\webserver\www\feeder\index.php(7): SoapClient->getProxy() #2 {main} thrown in C:\webserver\www\feeder\index.php on line 7
here's my code :
<?php
$wsdl = "http://localhost:8182/fg/live.php?wsdl";
$username = "aaaaa";
$password = "123456";
$client = new SoapClient($wsdl);
$proxy = $client->getProxy();
$token = $proxy->GetToken($username, $password);
var_dump("Get Token = ".$token);
$table = $proxy->ListTable($token);
var_dump("Tabel = ".$table);
?>
There's something wrong with my code ?
Please have a look at the PHP SoapClient Doku, there is no getProxy-Method. The client itself calls the functions defined in wsdl:
$token = $client->GetToken();
$client->ListTable($token);
And make shure, that you check $token, if it's really a single variable, or if it is an object.

PHP SOAP : Object reference not set to an instance of an object

I need your help
I have to use PHP functions from a web service SOAP
The request XML is as follows
<OTA_HotelDescriptiveInfoRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="1">
<POS>
<Source AgentSine="user" AgentDutyCode="pass" />
</POS>
<HotelDescriptiveInfos>
<HotelDescriptiveInfo ChainCode="H4U" HotelCode="696"/>
</HotelDescriptiveInfos>
</OTA_HotelDescriptiveInfoRQ>
Here is my PHP code:
$soapClient = new SoapClient("http://otatest.apixml.com/dispatcher.asmx?WSDL");
$header = new SOAPHeader('http://xmlota.wspan.com/webservice/', 'authentication', array('username' => 'user', 'password' => 'pass'));
$soapClient->__setSoapHeaders($header);
$param['POS']['Source']['AgentSine'] = 'user';
$param['POS']['Source']['AgentDutyCode'] = 'pass';
$param['HotelDescriptiveInfos']['HotelDescriptiveInfo']['ChainCode'] = 'H4U';
$param['HotelDescriptiveInfos']['HotelDescriptiveInfo']['HotelCode'] = '696';
$response = $soapClient->sendOTAHotelDescriptiveInfo($param);
And here is the error I'm trying for several days but I can not resolve it
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request.
---> System.NullReferenceException: Object reference not set to an instance of an object. at H4U.Webservices.OTA.SoapDispatcher.sendOTAHotelDescriptiveInfo(OTA_HotelDescriptiveInfoRQ OTA_HotelDescriptiveInfoRQ)
--- End of inner exception stack trace ---
in /home/dimavoya/public_html/soap/soap.php:43
Stack trace:
#0 /home/dimavoya/public_html/soap/soap.php(43): SoapClient->__call('sendOTAHotelDes...', Array)
#1 /home/dimavoya/public_html/soap/soap.php(43): SoapClient->sendOTAHotelDescriptiveInfo(Object(SoapVar))
#2 {main} thrown in
I remain at your disposal for more information
Thank you in advance

how do i call a method from a wsdl

i am trying to call a method from a wsdl and getting an error. i am new to soap and learning all i can. i know rest is better but i really want to learn soap. this is what i have so far:
ini_set('soap.wsdl_cache_enable', '0');
$client = new SoapClient('http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl');
$data = $client->__soapCall('GetQuote', array('GetQuote' => 'aapl'));
print $data;
the error i get is
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in /Volumes/www/public/soap/s.php:5 Stack trace: #0 /Volumes/www/public/soap/s.php(5): SoapClient->__soapCall('GetQuote', Array) #1 {main} thrown in /Volumes/www/public/soap/s.php on line 5
thanks
You can see all required parameters for the GetQuote request in http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl
You should pass a StockSymbol and LicenseKey. Example of request:
ini_set('soap.wsdl_cache_enable', '0');
$client = new SoapClient('http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl');
$data = $client->GetQuote(array('StockSymbol' => 'TEST_STR','LicenseKey' => 'TEST_STR'));
print_r($data);
Replace TEST_STR with your data

Categories