I'm trying to call a function from this webservice:
http://www.zulutrade.com/WebServices/Performance.asmx?WSDL
I'm sending all the requested params but I'm getting this error: Value cannot be null. Parameter name: source
I think it's a server issue, but maybe I need to change something in my code:
$client = new SoapClient('http://www.zulutrade.com/WebServices/Performance.asmx?WSDL',
array('location' => "http://www.zulutrade.com/WebServices/Performance.asmx",
'trace'=>1,
"cache_wsdl" => 0));
$params = array
(
'providerId' => 109206,
'fromDateStr' => "1985-12-19",
'toDateStr' => "2013-05-06",
'validTrades' => true,
'lotSize' => "Mini",
'start' => 0,
'length' => 20,
'sortBy' => "buy",
'sortAscending' => true
);
try
{
$result = $client->GetProviderTrades($params);
}
catch (SoapFault $fault)
{
print_r($fault);
}
Any ideas?
thanks
I tried with nusoap class and I get this error
HTTP Error: Couldn't open socket connection to server http://www.zulutrade.com:81/WebServices/Performance.asmx, Error (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
So maybe it's a bug on their part
You set all vars except one. ArrayOfInt currencyIds; is not set.
struct GetProviderTrades {
int providerId;
ArrayOfInt currencyIds;
string fromDateStr;
string toDateStr;
boolean validTrades;
LotSize lotSize;
int start;
int length;
string sortBy;
boolean sortAscending;
}
Related
I have a soapClient call that works fine with PHP 5.6 (RH6). We are upgrading the system to PHP 7 (RH7 with the same configuration as the previous one) but the same call does not work.
This is my code
$wsdlUrl = "https://THE_URL_I_AM_CALLING/repository/soap/2.1?wsdl";
$sslClientCert = "../../app/config/ssl/ssl_cert.crt";
$sslClientKey = "../../app/config/ssl/ssl_cert.key";
$proxy = 'proxy_http';
$port = 8080;
$contextOptions = [
'ssl' => [
'local_cert' => $sslClientCert,
'local_pk' => $sslClientKey,
'SNI_enabled' => true,
'SNI_server_name' => 'THE_URL_I_AM_CALLING'
]
];
$options= [
"soap_version" => SOAP_1_2,
"features" => SOAP_SINGLE_ELEMENT_ARRAYS,
"stream_context" => stream_context_create($contextOptions),
'proxy_host' => $proxy,
'proxy_port' => $port
];
$client = new SoapClient($wsdlUrl, $options);
try {
// execute the search
$searchResults = $client->searchDocuments([
"text" => "myText",
"hint" => "document"
]);
}
catch (Exception $e) {
echo $e->getMessage();
}
the error I get under PHP 7 is
PHP Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host
if I make the call using CURL it works.
I would rather use clientSoap to make my life easier.
I found the solution. Posting it here so no other soul on earth needs to go through this ordeal.
According to the documentation
http://php.net/manual/en/context.ssl.php#context.ssl.sni-server-name
SNI_server_name (string):
If set, then this value will be used as server name for server name indication. If this value is not set, then the server name is guessed based on the hostname used when opening the stream.
Note: This option is deprecated, in favour of peer_name, as of PHP
5.6.0.
After changing:
'SNI_server_name' => 'THE_URL_I_AM_CALLING'
with
'peer_name' => 'THE_URL_I_AM_CALLING'
It works.
I have an ecommerce website which is under development right now. I bought a web software. I want to connect to the webservice and add some brands.
This is my webservice WSDL url: http://www.cantabu.com/Servis/UrunServis.svc?wsdl
The method for adding a new brand is "SaveMarka".
This is my initial code:
ini_set("soap.wsdl_cache_enabled", "0");
$wsdl = "http://www.cantabu.com/Servis/UrunServis.svc?wsdl";
$authCode = "MY_WEBSERVICE_AUTHENTICATION_CODE";
$client = new SoapClient($wsdl);
When i print_r $client->__getFunctions() The result is (Related to SaveMarka method):
Array
(
[4] => SaveMarkaResponse SaveMarka(SaveMarka $parameters)
)
And when i print_r $client->__getTypes(), the result is (Up to 5th index of the result array, because others are unrelated to SaveMarka):
Array
(
[0] => struct ArrayOfint {
int int;
}
[1] => struct ArrayOfstring {
string string;
}
[2] => struct ArrayOfKategori {
Kategori Kategori;
}
[3] => struct Kategori {
boolean Aktif;
int ID;
string Icerik;
string Kod;
int PID;
string SeoAnahtarKelime;
string SeoSayfaAciklama;
string SeoSayfaBaslik;
int Sira;
string Tanim;
}
[4] => struct ArrayOfMarka {
Marka Marka;
}
[5] => struct Marka {
boolean Aktif;
int ID;
string SeoAnahtarKelime;
string SeoSayfaAciklama;
string SeoSayfaBaslik;
string Tanim;
}
In their web service document, they say; if you want to add a new brand, the ID should be 0 (zero). Otherwise, whe webservice will update the brand related to that ID.
I have tried different variations of SaveMarka method. But they all failed with varied results.
First of all, i have created a Marka class.
class Marka{
var $ID;
var $SeoAnahtarKelime;
var $SeoSayfaBaslik;
var $SeoSayfaAciklama;
var $Tanim;
var $Aktif;
function __construct($id, $seo, $seoAciklama, $seoBaslik, $ad){
$this->ID = $id;
$this->SeoAnahtarKelime = $seo;
$this->SeoSayfaBaslik = $seoBaslik;
$this->SeoSayfaAciklama = $seoAciklama;
$this->Tanim = $ad;
$this->Aktif = true;
}
}
Then i have tried to do this:
$marka = new Marka(0, "pg", "P&G", "P&G", "P&G");
$newMarka = array(
"UyeKodu" => $authCode",
"Marka" => $marka
);
$client->__soapCall("SaveMarka", $newMarka);
The result is:
Type: SoapFault
Message: The formatter threw an exception while trying to deserialize
the message: Error in deserializing body of request message for
operation 'SaveMarka'. End element 'Body' from namespace
'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element
'param1' from namespace ''. Line 2, position 150.
I also tried (I don't know why):
$marka = new Marka(0, "pg", "P&G", "P&G", "P&G");
$newMarka = array(array(
"UyeKodu" => $authCode",
"Marka" => $marka
));
$client->__soapCall("SaveMarka", $newMarka);
And the result is:
Type: SoapFault
Message: Object reference not set to an instance of an object.
Then i get rid of the Marka class and tried to do it simpler without using a class:
$newMarka = array(
"UyeKodu" => $authCode,
"ID" => 0,
"Tanim" => "P&G",
"Aktif" => true,
"SeoAnahtarKelime" => "pg",
"SeoSayfaBaslik" => "P&G",
"SeoSayfaAciklama" => "P&G"
);
$client->__soapCall("SaveMarka", $newMarka);
Result is:
Type: SoapFault
Message: The formatter threw an exception while trying to deserialize
the message: Error in deserializing body of request message for
operation 'SaveMarka'. End element 'Body' from namespace
'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element
'param1' from namespace ''. Line 2, position 150.
And also (again, i don't know why)
$newMarka = array(array(
"UyeKodu" => $authCode,
"ID" => 0,
"Tanim" => "P&G",
"Aktif" => true,
"SeoAnahtarKelime" => "pg",
"SeoSayfaBaslik" => "P&G",
"SeoSayfaAciklama" => "P&G"
));
$client->__soapCall("SaveMarka", $newMarka);
And the result is:
Type: SoapFault
Message: Object reference not set to an instance of an object.
What am i doing wrong?
Can anyone please help me with adding a new brand? I have supplied the functions, types, wsdl link and all my tries.
Please, help.
i have a problem with running methods with SOAP. I'm using Apache and PHP.
this is the PHP code:
$opts = array(
'ssl' => array('ciphers'=>'RC4-SHA')
);
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$client = new SoapClient('https://host?wsdl', array (
'stream_context' => stream_context_create($opts),
"trace" => 1,
"exceptions" => 0,
"connection_timeout"=>2000));
var_dump($client->__getFunctions());
$params = array ("key" => "value");
$result = $client->availabeFunction($params);
var_dump($result);
The __getFunctions() It returns me all of the available functions.
Then when i'm trying to call the the available function with parameters.
It returns me a strage error message:
public 'faultstring' => string 'Could not connect to host' (length=25)
public 'faultcode' => string 'HTTP' (length=4)
So i presume it is for some reasons are connecting to through the HTTP, but not through HTTPS.
I've looked up the web, and in some cases they are using a local_cert value with a .pem file.
It it neccecity to have it? Or i'm missing something else?
It's an openssl library bug.
At first try to disable SSL check by adding this params
"stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
)
And next try to not use ?wsdl in location link, try use something like
.wsdl
The solution was much easier as i thoguht it will be:
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$location = 'https://host';
$client = new SoapClient($location . '?wsdl', array (
"trace" => 1,
"exceptions" => 0,
"connection_timeout"=>2000,
"location"=>$location // <- this was the reqiured parameter
));
Everything else is same as before.
This beeing cause by WSDL file configuration, that instead of https URL, it has http.
The following soap request
$response = $this->client->__soapCall('Match', array('word' => 'test', 'strategy' => 'exact'));
yields the error
Uncaught SoapFault exception: [soap:Client] Parameter not specified (null)
Parameter name: word
How can this be? I specified the word parameter in the request, didnt I? Why doesn's the server recognize it?
The service I want to use is an online dictionary webservive
Generally you need to wrap the arguments in a double array:
$response = $this->client->__soapCall('Match', array(array('word' => 'test', 'strategy' => 'exact')));
It reads a bit nicer if you
$aParams = array('word' => 'test', 'strategy' => 'exact');
$response = $this->client->__soapCall('Match', array($aParams));
Or you can simply call the Match function directly
$aParams = array('word' => 'test', 'strategy' => 'exact');
$response = $this->client->Match($aParams);
Or, as a final resort, use the HTTP GET option: http://services.aonaware.com/DictService/DictService.asmx?op=Match
Should get you on the road again.
I'm attempting to access this web service via SOAP from PHP using this code:
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.neugroup.com/workarea/servercontrolws.asmx?WSDL";
$username = 'username';
$password = 'password';
$client = new SoapClient($wsdl_path, array(
"trace" => 1,
"exceptions" => 0)
);
try {
$result = $client->LoadListSummary(array(
'LangID' => 1033,
'FolderPath' => 'path/',
'MaxResults' => 500,
'OrderKey' => 'Title',
'Direction' => 'Ascending',
'Preview' => 0,
'Recursive' => 0,
'RetrieveSummary' => 0,
'Random' => 0,
'GetHtml' => 0,
'ContentType' => 'AllTypes',
)
);
}
catch (SoapFault $exception) {
echo $exception;
}
but I get an "Object reference not set to an instance of an object" error. I'm stepping through this is a debugger, and I can see that $client is an object. Is there something else I'm doing wrong that would cause this error? Also, am I structuring my SOAP call correctly?
Thanks.
It doesn't look like you are doing anything wrong, the error is in the service so one of two things can be the case:
One of your parameters is wrong and makes the service resolve to a null object (path could be a candidate) and the server doesn't validate this and try to so operations on the object
There is a general malfunction in the service you are calling