Thank you all in advance for the help:
I have this code:
require_once('include/nusoap/lib/nusoap.php');
$soapclient = new soapclient('http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx');
print_r( $soapclient->call( 'TipoCambioDia' ) );
and gives me this error:Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx' : Premature end of data in tag html line 3 in C:\xampp\htdocs\cambio_moneda\cambio_moneda.php:3 Stack trace: #0 C:\xampp\htdocs\cambio_moneda\cambio_moneda.php(3) : SoapClient->SoapClient('http://www.bang...') #1 {main} thrown in C:\xampp\htdocs\cambio_moneda\cambio_moneda.php on line 3
Then I tried with this code:
require_once('include/nusoap/lib/nusoap.php');
$soapclient = new soapclient();
$result = $soapclient->call( 'TipoCambioDia' , array(), "http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx?op=TipoCambioDia", "http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx?op=TipoCambioDia");
print_r( $result );
And I get this error results:Fatal error: Uncaught SoapFault exception: [Client] SoapClient::SoapClient(): Invalid parameters in C:\xampp\htdocs\cambio_moneda\cambio_moneda.php:3 Stack trace: #0 C:\xampp\htdocs\cambio_moneda\cambio_moneda.php(3) : SoapClient->SoapClient() #1 {main} thrown in C:\xampp\htdocs\cambio_moneda\cambio_moneda.php on line 3
What I want to accomplish is to get the exchange rate plus the date and store it in a variable
Thanks to all
The reason for the fatal error is that the URL you are using to create $soapclient is not a WSDL file. You will need to change it (note the ?WSDL in the URL):
$soapclient = new soapclient('http://www.banguat.gob.gt/variables/ws/TipoCambio.asmx?WSDL');
Next, to get "TipoCambioDia" call, you need to use it directly, i.e.:
$soapclient->TipoCambioDia()
Doing this will return in a stdObject:
stdClass Object
(
[TipoCambioDiaResult] => stdClass Object
(
[CambioDolar] => stdClass Object
(
[VarDolar] => stdClass Object
(
[fecha] => 30/01/2015
[referencia] => 7.65538
)
)
[TotalItems] => 1
)
)
Related
When sending a request from my PHP soapclient as described below, I get:
[getInterestAndExchangeRates failed: Please check inparameters in Xxx].
I suspect that it is the [$response] line that has wrong syntax. More specific the [$searchRequestParameters]. I have checked that all the content in the array is in the correct order.
Question:
Is there something wrong with below code syntax?
I have followed following instructions:
https://swea.riksbank.se/sweaWS/docs/api/call/getInterestAndExchangeRates.htm
<?php
/**
* A soapclient request to Swedish Central bank, API.
*/
$client = new SoapClient("https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl");
$searchGroupSeries = array(
"groupid" => 2,
"seriesid" => "SECBREPOEFF"
);
$searchRequestParameters = array (
"aggregateMethod" => "W",
"avg" => true,
"datefrom" => "2018-01-01",
"dateto" => "2019-01-01",
"languageid" => "en",
"max" => true,
"min" => false,
"searchGroupSeries" => $searchGroupSeries,
"ultimo" => false
);
// Test 1 (pointing out above array, does not work):
$response = $client->__soapCall("getInterestAndExchangeRates", $searchRequestParameters);
// Test 2 (wrap in above array inside another array, does not work):
// $response = $client->__soapCall('getInterestAndExchangeRates', array('searchRequestParameters' => $searchRequestParameters));
var_dump($response);
Error:
PHP Fatal error: Uncaught SoapFault exception: [soap:Server] getInterestAndExchangeRates failed: Please check inparameters in [path]_(does_not_work).php:22
Stack trace:
#0 [path]_(does_not_work).php(22): SoapClient->__soapCall('getInterestAndE...', Array)
#1 {main}
thrown in [path]_(does_not_work).php on line 22
I am trying to create a SOAP Client from a WSDL file, but I always get this error bellow.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'https://..../CreateQuote?xsd=createQuote_datamodel.xsd', namespace must not match the enclosing schema 'targetNamespace' in C:\xampp\htdocs\kfz\test.php:23 Stack trace: #0 C:\xampp\htdocs\kfz\test.php(23): SoapClient->SoapClient('https://testws1...', Array) #1 {main} thrown in C:\xampp\htdocs\kfz\test.php on line 23
Here is my code:
$xml = file_get_contents("out.xml");
$soapOptions = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wsdl_local_copy' => false,
'keep_alive' => true,
);
$soapClient = new SoapClient($wsdlUrl, $soapOptions);
$soapClient->CreateQuote($xml);
Can anyone help me please?
I also tried it with non WSDL mode but it's still not working
I am using third party SOAP API to get users details
$wsdl = 'https://sample.ifuture.com/sites/sample.xxxx.com/api/isession.php?wsdl';
$client = new SoapClient($wsdl, array ( 'username'=>'testusername', 'password'=>'testpassword'));
print_r($client->__getFunctions());
When I use SoapClient() I am successfully connect to WSDL, last statement return the function list of the WSDL.
Result
Array
(
[0] => boolean iLoggedOn(string $session)
[1] => boolean iLogOff(string $session)
[2] => boolean iLogOn(string $session, string $username, string $password)
[3] => boolean iPasswd(string $session, string $username, string $password)
[4] => list(boolean $return, string $message) iSync(string $username, string $action, string $values)
)
Now I am trying to use the SOAP __Call() to invoke soap method
$param = array(
"sessionid" =>"12345678900987654321abcisfetul12",
"username" =>"test",
"password"=>"test");
$client->__Call('iLogOn', $param);
The execution of above statement generates an error as mentioned below
Fatal error: Uncaught SoapFault exception: [HTTP] Authorization Required in /opt/lampp/htdocs/demo/saop/index.php:79 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://sample....', 'https://sample....', 1, 0) #1 /opt/lampp/htdocs/demo/saop/index.php(79): SoapClient->__call('iLogOn', Array) #2 {main} thrown in /opt/lampp/htdocs/demo/saop/index.php on line 79
Looking forward for appropriate solution.
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 can parse the .WSDL file and call the functions using soapUI, but not
using PHP5. It has also been shown to work with JAVA/AXIS and .NET.
I need the WSDL caching functionality of the PHP5 SOAP procedures
otherwise I might stick with soapUI.
Reproduce code:
$optional = array
(
'trace' => 1,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'encoding' => 'ISO-8859-1'
);
$wsdl = 'https://www-a.audanet.de/b2b/services/AXAttachmentService?wsdl';
$client = new SoapClientAuth($wsdl, $optional);
Expected result:
A useable instance of a SoapClient object.
Actual result:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected 'attribute' in complexType in ../class/SoapClientAuth.php:62
Stack trace:
0 ../class/SoapClientAuth.php(62): SoapClient->SoapClient('https://www-a.a...', Array)
1 ../class/Ws.php(30): SoapClientAuth->SoapClientAuth('https://www-a.a...', Array)
2 ../zalacz.php(468): Ws->podlaczenieWS()
3 {main}
thrown in ../class/SoapClientAuth.php on line 62