Error while posting a request via soap client - php

I have implemented arzoo Flight API in my php web site.
I have used soap client to send the request. while browsing I got the following error
HERE IS A FAULT : SoapFault exception: [HTTP] Error Fetching http headers in /home/wwwkomet/public_html/demo1/dom_avail.php:71 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('getAvailability', Array) #2 {main}
This is my code
$location_URL = "http://59.162.33.102/ArzooWS/services/DOMFlightAvailability";
$action_URL ="http://com.arzoo.flight.avail";
$client = new SoapClient('http://59.162.33.102/ArzooWS/services/DOMFlightAvailability?wsdl', array(
'soap_version' => SOAP_1_1,
'location' => $location_URL,
'uri' => $action_URL,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'trace' => 1,
));
try
{
$result = $client->__call('getAvailability',array($req_int));
$response= htmlentities($result);
}
What is the reason to this? How to overcome this error?
Thanks in advance

I just working on the same Arzoo Flight search API, Your code just worked for me Where as i just added catch to the above code:
catch(Exception $e){
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
For the response to be print u just use:
var_dump($response);

Related

PHP __SoapCall issue

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

Getting Unauthorized when I called a function in SOAP via php

After when I am connected successfully, I'm getting all of the function using __getFunctions(); when I call a function im getting this : Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in /home/netlogiq/public_html/CUSTOM/attin/h_b/db.php:12 Stack trace.
This is my code:
$client = new SoapClient("WebItem.wsdl", array('proxy_host' => "83.166.204.26",
'proxy_port' => 7147,
'proxy_login' => "xxxxx",
'proxy_password' => "xxxxx",
'trace' => true,
'exception' => true ));
echo "<pre>"; var_dump($client->__getFunctions()); echo "</pre>";
echo "<br>";
$client->__soapCall("Read" , array('No'=>'142JC242'));
Actually I want to know what should I do to get rid of this bug ? and how i getting all the items from the image bellow ?. The image represent the SOAP UI interface, version 5.0. thx

Write username to httpheader for web service authetification with php

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?

PHP SOAP with HTTPS webservice and .PEM client certificate

How to create PHP SOAP with HTTPS webservice and .PEM client certificate ?
When i did that i received the follow errors:
array(2) { [0]=> string(38) "testeResponse teste(teste $parameters)" [1]=> string(38) "testeResponse teste(teste $parameters)" }
Fatal error: Uncaught SoapFault exception: [wsse:InvalidSecurity] SOAP header missing in D:\Inetpub\wwwroot\SOAP\index.php:47 Stack trace: #0 [internal function]: SoapClient->__call('teste', Array) #1 D:\Inetpub\wwwroot\SOAP\index.php(47): SoapClient->teste(Array) #2 {main} thrown in D:\Inetpub\wwwroot\SOAP\index.php on line 47
The code:
$client = new SoapClient($wsdl, array(
'local_cert' => $localCert,
'passphrase' => $passphrase,
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL,
'exceptions' => true,
'trace' => true)
);
$something = $client->teste(array());
echo $something->testeResult;
The warning is not about the PEM certificate or SSL. It is simply:
SOAP header missing
You find SOAPHeader in the PHP manual. There are some usage examples and user contributed notes in the PHP manual and also here on this website, too. For example:
$auth = array(
'UserName' => 'USERNAME',
'Password' => 'PASSWORD',
'SystemId' => array('_'=> 'DATA', 'Param' => 'PARAM'),
);
$header = new SoapHeader('NAMESPACE','Auth',$auth,false);
$client->__setSoapHeaders($header);
Let me know if you run into problems.

How to change the namespace sent with a SOAP request?

Related to this question: How to request an answer from a SOAP XML API?
I have this PHP script sending the request with the required fields:
$client = new SoapClient('https://live.domainbox.net/?WSDL');
$params = array(
'AuthenticationParameters' => array(
'Reseller' => 'resellername',
'Username' => 'myusername',
'Password' => 'mypassword'
),
'CommandParameters' => array(
'DomainName' => 'mydomain.com',
'LaunchPhase' => 'GA'
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
I get the following error message:
Fatal error: Uncaught SoapFault exception: [soap:VersionMismatch]
Possible SOAP version mismatch: Envelope namespace
http://schemas.xmlsoap.org/soap/envelope/ was unexpected.
Expecting http://www.w3.org/2003/05/soap-envelope. in
/home/nosa/public_html/dev/check-domain-availability.php:20 Stack
trace: #0
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->__call('CheckDomainAvai...', Array) #1
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->CheckDomainAvailability(Array) #2 {main} thrown in
/home/nosa/public_html/dev/check-domain-availability.php on line 20
I removed and recompiled apache to include the latest SOAP version available using WHM/cPanel.
My question is:
How do I send the correct envelope namespace?
When building your soap_client object, you can pass an option's array, by default, the version will be 1.1 as per php documentation.
The error you have seems to point out that the service might be SOAP 1.2 so you need to set it to 1.2...
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
Try that out!

Categories