I have a PHP Client.
The Server WSDL is https://34.200.105.231/VENTAS_SOAP/VentaService.svc?wsdl
The webservices generated by the session work without any problems
$params = array('soap_version' => SOAP_1_2);
$ws = new SoapClient(
'https://34.200.105.231/VENTAS_SOAP/VentaService.svc?wsdl',
$params
);
$parametros = array( 'sesion' => array(
'IDSesion' => "44444",
'IDCliente' => "rick",
'IDEmpresa' => "rick",
'IDUsuario' => "user",
'Token' => '',
),'codigo' => 'ac',
'descripcion' => '',
'cantidadRegistros' => '1',
'pagina' => '0'
);
print_r(print_r($ws->__soapCall("ConsultaArticulosServicios",$parametros)));
Not work, Response:
Fatal error: Uncaught SoapFault exception:
[HTTP] Could not connect to host in /home/admin/web/xxxxxxxx/public_html/nusoapfontana/metodos/index3.php:41
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://df-0e7d...', 'VentaServicio/V...', 2, 0)
#1 /home/admin/web/xxxxxxxx/public_html/nusoapfontana/metodos/index3.php(41): SoapClient->__soapCall('ConsultaArticul...', Array)
#2 {main} thrown in /home/admin/web/xxxxxxxx/public_html/nusoapfontana/metodos/index3.php on line 41
If I can access the Login function found here:
Http://34.200.105.231/SID/Service.svc?wsdl
Here I generate the data for the session.
Related
This request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Buy xmlns="http://tempuri.org/">
<perf>
<param1>1111</param1>
<param2>2222</param2>
</perf>
</Buy>
</soap:Body></soap:Envelope>
I create request with SoapClient:
$client = new SoapClient("http://0.0.0.0:8080/Service1.asmx?wsdl",
array(
'trace' => true,
'exceptions'=>true
));
Function "getTypes" and "getFunctions" work correct
$types = $client->__getTypes();
$functions = $client->__getFunctions ();
I'm creating object and I'm waiting result:
$std = new stdClass();
$std->param1 = '1111';
$std->param2 = '2222';
ini_set("soap.wsdl_cache_enabled", "0"); // disallow cache WSDL
$result = $client->Buy( array('perf' => $std ) );
var_dump($result); exit;
I got an error: SoapFault:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /var/www/index.php:86 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('Buy', Array) #2 /var/www/index.php(86): SoapClient->Buy(Array) #3 {main} thrown in /var/www/index.php on line 86
In the logs of apache:
PHP Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /var/www/index.php:86\nStack trace:\n#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://0.0.0...', 'http://tempuri....', 1, 0)\n#1 /var/www/index.php(86): SoapClient->__call('Buy', Array)\n#2 /var/www/index.php(86): SoapClient->Buy(Array)\n#3 {main}\n thrown in /var/www/index.php on line 86
Please, help me), may be, I created object with parameters not correct?
Try not to mix arrays and objects. Check this:
$result = $client->Buy( array('perf' => array('param1' => '1111', 'param2' => '2222')) );
Or this:
$result = $client->Buy( (object) array('perf' => (object) array('param1' => '1111', 'param2' => '2222')) );
I have a simple service using php and Soap
There's a function named getPrice in my SOAP SERVER
This is getPrice :
function getPrice($productISBN, $param)
{
return $productISBN;
}
$kks = new SoapServer(null, array('uri' => "urn://my/webservice/shop"));
$kks->addFunction( array(
'getPrice',
'reserveProduct',
'inquiryPostPrice',
'registerPostOrder'
) );
$kks->addFunction(SOAP_FUNCTIONS_ALL);
$kks->handle();
and this is my client file -This is in /kkc folder :
$client = new SoapClient(null, array(
'location' => "http://example.com/webservice/kks/shop.php",
'uri' => "urn://my/webservice/shop"
) );
var_dump( $client->__soapCall('getPrice', array(123456789, $param) ) );
//$param is a string
but I'll get this error in client :
Fatal error: Uncaught SoapFault exception: [HTTP] Internal Server
Error in /example.com/webservice/kkc/client.php:28 Stack trace:
#0 [internal function]: SoapClient->__doRequest('__soapCall('getPrice', Array)
#2 {main} thrown in /example.com/public_html/webservice/kkc/client.php on line 28
I have two other files like this and there's everything is fine...
Would you please let me know what's wrong here?
Thanks in Advance
I am trying to get data from an API service using SOAP.Everything works fine except the data.
Here is the code
$body=array(
'Origin' => 'BOM',
'Destination' => 'DEL',
'DepartDate' => '2013-09-05',
'ReturnDate' => '2013-09-06',
'AdultPax' => '1',
'ChildPax' => '0',
'InfantPax' => '0',
'Currency' => 'INR',
'Clientid' => 'XXX',
'Clientpassword' => '*4X',
'Clienttype' => 'XXXX',
'Preferredclass' => 'E',
'mode' => 'ONE',
'PreferredAirline' => 'AI,G8,IC,6E,9W,S2,IT,9H,I7,SG');
Php code for executing SOAP
$location_URL='http://59.162.33.102/ArzooWS/services/DOMFlightAvailability?wsdl';
$client = new SoapClient('http://59.162.33.102/ArzooWS/services/DOMFlightAvailability?wsdl');
try
{
print_r($client->__getFunctions());
$result = $client->__call('getAvailability',$body);
print_r($result);
}catch(Exception $e){
echo $e;
}
Result of print_r($client->__getFunctions()) returns getAvailability,when try to get the data i will get the exception
SoapFault exception: [soap:Server] Index: 1, Size: 1 in C:\xampp\htdocs\apihack\index.php:80 Stack trace: #0 C:\xampp\htdocs\apihack\index.php(80): SoapClient->__call('getAvailability', Array) #1 {main}
The following code worked before updating elasticsearch-php from 1.3.1 to 1.3.2:
$client = new Elasticsearch\Client();
// Index Settings
$indexParams['index'] = 'address';
// Example Index Mapping
$myTypeMapping = array(
'_source' => array(
'enabled' => true
),
'properties' => array(
'post_code' => array(
'type' => 'string',
'index' => 'not_analyzed'
)
)
);
$indexParams['body']['mappings']['postcode'] = $myTypeMapping;
// Create the index
$client->indices()->create($indexParams);
The error is as follows:
Fatal error: Uncaught exception
'Guzzle\Http\Exception\ClientErrorResponseException' with message
'Client error response [status code] 400 [reason phrase] Bad Request
[url] http://localhost:9200/address' in
C:\xampp\htdocs\locatr\vendor\guzzle\http\Guzzle\Http\Exception\BadResponseException.php:43
Stack trace: #0
C:\xampp\htdocs\locatr\vendor\guzzle\http\Guzzle\Http\Message\Request.php(145):
Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest),
Object(Guzzle\Http\Message\Response)) #1 [internal function]:
Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event),
'request.error',
Object(Symfony\Component\EventDispatcher\EventDispatcher)) #2
C:\xampp\htdocs\locatr\vendor\symfony\event-dispatcher\Symfony\Component\EventDispatcher\EventDispatcher.php(164):
call_user_func(Array, Object(Guzzle\Common\Event), 'request.error',
Object(Symfony\Component\EventDispatcher\EventDispatcher)) #3
C:\xampp\htdocs\locatr\vendor\symfony\event-dispatcher\Symfony\Component\Eve
in
C:\xampp\htdocs\locatr\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\GuzzleConnection.php
on line 266
Are there any changes between these versions that would break the code? There is nothing as far as I could see from the documentation.
Or is there an issue with the code sample? or is something else more likely?
My code:
$url = "http://x.x.x.x/ws/special/Service?wsdl";
$context = stream_context_create(array('http' => array( 'username' => "jonas" )));
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
$res = $client->__soapCall("getinfo",array('counter'=>'10'));
Error:-
Fatal error: Uncaught SoapFault exception: [S:Server] missing parameter
'username' in C:\xampp\htdocs\test.php:7 Stack trace: #0
C:\xampp\htdocs\test.php(7): SoapClient->__soapCall('getAsinfo...', Array)
#1 {main} thrown in C:\xampp\htdocs\test.php on line 7
How to write to http header?