Getting Unauthorized when I called a function in SOAP via php - 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

Related

PHP Soapclient returns object has no property

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

Fatal Error in Awin API - Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from

I have a very serious issue. I am working witht he API - https://ui.awin.com/awin/affiliate/250615?region=gb and after login into that, i found the api documentation and also php api client zip.
I then downloaded this client zip, updated all my api details and when i run - http://202.131.107.107/searchcycle/ps_client.php , I always get error as below -
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://v6.core.com.productserve.com/ProductServeService.wsdl' : failed to load external entity "http://v6.core.com.productserve.com/ProductServeService.wsdl" in /var/www/html/searchcycle/classes/class.php5Client.php:57 Stack trace: #0 /var/www/html/searchcycle/classes/class.php5Client.php(57): SoapClient->SoapClient('http://v6.core....', Array) #1 /var/www/html/searchcycle/classes/class.php5Client.php(95): Php5Client->__construct(Object(stdClass)) #2 /var/www/html/searchcycle/classes/class.ClientFactory.php(60): Php5Client::getInstance(Object(stdClass)) #3 /var/www/html/searchcycle/ps_client.php(29): ClientFactory::getClient() #4 {main} thrown in /var/www/html/searchcycle/classes/class.php5Client.php on line 57
Can someone please help me in this what is missing from my side.
Add optional SSL parameters.
How to solve:
// options for ssl in php 5.6.5
$opts = array(
'ssl' => array(
'ciphers' => 'RC4-SHA',
'verify_peer' => false,
'verify_peer_name' => false
)
);
// SOAP 1.2 client
$params = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts) // Magic happens here
);
$wsdlUrl = $url . '?WSDL';
$oSoapClient = new SoapClient($wsdlUrl, $params);
Please check this question, you would find something useful.

PHP SOAP Error Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from

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

soap parsing unexpected in complextype

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

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