I am trying to connect and use a WebService with PHP and SoapClient, but getting the following error
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /www/1/html/webservices/tuev-nord-ass/soapclientconnect.php:21
I have SOAP already installed. But still dont know why i am getting this error. I am new to web services and might be doing mistake somewhere.
WSDL link:
http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl
My code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl', '0');
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$client = new SoapClient($wsdl,
array(
'Benutzer' => 'desenbeck',
'Kennwort' => 'desenbeck',
'KonzernID' => '100',
'Händler-Nr' => 'INT31303',
'DMS-ID' => 'A13T2D19',
'encoding'=> 'ISO-8859-1'
)
);
//Returns list of available SOAP functions described in the WSDL for the Web service.
var_dump($client->__getFunctions());
//some parameters to send
$result = $client->Login('Benutzer', 'Kennwort', 'KonzernID', 'Händler-Nr', 'DMS-ID');
var_dump($result);
?>
Use a string indexed array for parameter:
$param = array ('user' => 'test',
'password' => 'test',
'corporate_group_id' => 'test',
'dealer_number' => 'test',
'dms_id' => 'test',
'dms_image_url' => 'test',
'dms_keepalive_url' => 'test',
'dms_followup_url' => 'test');
//some parameters to send
$result = $client->Login($param);
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.
there is a problem trying to execute some functions from the WSDL I have. I connected to the WSDL using Basic Auth, I can see all the functions available with:$functions = $client->__getFunctions();
But then I try to execute any of them I get "[HTTP] Could not connect to host" error. My code here:
ini_set('default_socket_timeout', 150);
header('Content-Type: text/plain');
ini_set("soap.wsdl_cache_enabled", "0");
$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),
'login' => 'login',
'password' => 'password',
'cache_wsdl' => WSDL_CACHE_NONE
);
$url = "http://address/webservice/wsdl";
try {
$client = new SoapClient($url, $params);
$functions = $client->__getFunctions();
var_dump($functions);
$response = $client->__soapCall('function_name', array());
$client->function_name();
var_dump($response);
} catch (SoapFault $fault) {
echo '<br>'.$fault;
}
Any ideas? Now in the WSDL file I have a targetNamespace parameter which is "targetNamespace="http://192.168.0.253:85/webservice/soap"" can this be a legit WSDL file? I mean can the namespace be a localhost ip address? Maybe this needs to be fixed in the WSDL side?
Found the solution. What was missing:
'location' => "http://address/webservice/soap",
In parameters.
I am new to web services and might be doing small mistake somewhere.I am trying to connect and use a WebService with PHP and SoapClient and getting a following error:
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /www/1/html/webservices/tuev-nord-ass/soapclientconnect.php
WSDL link:
http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl
My code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl', '0');
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$client = new SoapClient($wsdl,
array(
'user' => 'tülsenbeck',
'password' => 'tülsenbeck',
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => '',
)
);
//Returns list of available SOAP functions described in the WSDL for the Web service.
var_dump($client->__getFunctions());
//some parameters to send
$result = $client>Login('user','password','corporate_group_id','dealer_number','dms_id','dms_image_url','dms_keepalive_url','dms_followup_url');
var_dump($result);
?>
You completely mess the function arguments up.
$options = array('trace' => true);
$params = array(
'user' => 'deshmukh',
'password' => 'deshmukh',
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => ''
);
$client = new SoapClient($wsdl, $options); // options!!!
$result = $client->Login($params); // params!!!
Now it replies with “Zugangsdaten sind nicht gültig,” I guess you’ll go further yourself.
MfG
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.
i am trying to calling .net webservice in php
below is my code.
<?php
$client = new SoapClient("http://test.etech.net/PanelIntegration/PanelIntegration.asmx?wsdl");
<?php
$sh_param = array(
'Username' => 'IntegratorLPI',
'Password' => 'password531');
$headers = new SoapHeader('http://wms.etech.net/', 'UserCredentials', $sh_param);
$client->__setSoapHeaders($headers);
$params = array('CustomerName' => 'Mr Smith','ContactMobileNo' => '01237 376347',
'AddressLine1' => '33 Amblecote Road',
'AddressTown' => 'Cambridgeshire',
'AddressPostCode' => 'NW23 6TR',
'VendorAddressLine1' => '80 Norton Road',
'VendorAddressTown' => 'Hickley ',
'VendorAddressCounty' => 'Cambridgeshire',
'VendorAddressPostCode' => 'NW23 2AQ',
'RegionalOfficeID' => '3',
'ExternalNotes' => 'Case Accepted',
'UPRN' => '',
'InstructionTypeID' => '2',
'PropertyTypeID' => '11',
'PropertyTenure' => '2',
'SurveyorID' => '23',
'RRN' => '0240-9002-0391-3520-0020',
'NewInstruction'=> 'true',
'StatusID' => '1'
);
$result = $client->__soapCall("UpdateInstruction", $params );
print_r( $result);
?>
i have got this error
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\xampp\htdocs\test2.php:33 Stack trace: #0 C:\xampp\htdocs\test2.php(33): SoapClient->__soapCall('UpdateInstructi...', Array) #1 {main} thrown in C:\xampp\htdocs\test2.php on line 33
You probably need to send something like:
$result = $client->__soapCall("UpdateInstruction", array('Instruction' => $params );
Where Instruction is the name of the object that you are passing.
It looks like a NullReferenceException was thrown on the server side. So, it's a matter of the parameters to whatever function is occurring on the server side generating that error.
Regardless of why, per best practices, this is an error in the .NET service. The NullReferenceException should really be replaced with something more specific.
Can you get in touch with whomever wrote the service to get more information to troubleshoot? It's quite possible that you have a parameter misnamed in your $params array, but you're probably going to need some help from the service writer.