My friends, I would like to know what I am doing wrong in my code in which it continues giving error of deserilization. When I set all parameters correctly it shows a class error (stdClass). Here is a wsdl print in SOAP UI and PHP code. I left the comment the options I have already tried.
<pre>
$soapParams = array('login' => 'master',
'password' => 'master',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0 );
$client = new SoapClient("http://189.60.63.128:8061/wsDataServe/MEX?wsdl",$soapParams);
//$result = $client->__soapCall("ReadView",$params);
//$result = $client->__soapCall("ReadView",array('DataServerName' => 'EduAlunoData', 'Filtro'=>'?', 'Contexto'=>'?'));
//$result=$client->__call("ReadView", ['ReadView' => ['DataServerName' => 'EduAlunoData', 'Filtro' => '1=1','Contexto'=>'?']]);
$result=$client->__soapCall("ReadView", ['DataServerName' => "EduAlunoData", 'Filtro' => '1=1','Contexto'=>'?']);
print $result;
</pre>
Image of the WSDL from SOAP UI
I solved the Problem:
<?php
$soapParams = array('login' => 'master',
'password' => 'master',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0
);
$params = array();
$client = new SoapClient("http://200.30.20.120:8051/wsDataServer/MEX?wsdl", $soapParams);
echo "Connected";
$params = array('DataServerName' => 'EduAlunoData', 'Filtro'=>'1=1', 'Contexto'=>'?');
var_dump($params);
$result = $client->ReadView($params);
echo "Response:\n" . $client->__getLastResponse() . "<br><br>";
//echo "<br>";
//echo "REQUEST:\n" . $client->__getLastRequest() . "<br><br>";
//echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "<br><br>";
//echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "<br><br>";
//var_dump($client->__getTypes());
//var_dump($client->__getFunctions());
//print $result;
?>
Related
Guys I have an issue I have been learning soap the last few days, I've been trying to connect to a web service for online store to verify users tv licenses before they can purchase a tv set.
I have written the following code to test the web service provided by TV licenses company.
<?php
$wdsl = "https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl";
$options = array(
'trace' => true,
'exceptions' => true,
'connection_timeout' => 1
);
try{
$client = new SoapClient($wdsl,$options);
$apiauth = array(
'Rquid' => '3600cd32-28b9-4a4f-a522-4326def4a9c2',
'ApiKey' => '5957237e-101c-4ff2-8fdc-4bd6c9393a1d',
'AccountIdentifier' => '9211186012088',
'AccountIdentifierType' => 'SaidNumber');
$header = new SoapHeader('http://tempuri.org/','Auth',$apiauth,true);
$client->__setSoapHeaders($header);
$account = $client->GetAccount();
var_dump($account);
echo "<pre>";
var_dump($client);
echo "</pre>";
}catch (Exception $e) {
echo "Error!";
echo $e->getMessage() . "<br>";
echo 'Last response: ' . $client->__getLastResponse();
}
?>
The wdsl does not require a client certificate, the api key above is for testing only.
The problem I always hit
unable to connect to host
But if I write an invalid function I get an error that the function is invalid for this services, When I use __GetFunctions() I do see the functions in the services, but when I try to use one of them I hit could not connect to host, Can guys help me out to connect to this service.
hopefully this should get you going, I assume that the live wsdl will work correctly without having to call __setLocation()
<?php
$wdsl = "https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl";
$options = array(
'trace' => true,
'exceptions' => true,
'connection_timeout' => 1
);
try {
$client = new SoapClient($wdsl, $options);
// use https location - the host for http (http://jhb-tvlicweb2.sabc.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc) dosn't exist
$client->__setLocation('https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc');
// setup parameters
$arrParams = array(
'request' => array(
'Header' => array(
'Rquid' => '3600cd32-28b9-4a4f-a522-4326def4a9c2',
'ApiKey' => '5957237e-101c-4ff2-8fdc-4bd6c9393a1d'
),
'AccountIdentifier' => '9211186012088',
'AccountIdentifierType' => 'SaidNumber'
)
);
// request parameters passed in the body not the header
$account = $client->GetAccount($arrParams);
var_dump($account);
echo "<pre>";
var_dump($client);
echo "</pre>";
} catch (\Exception $e) {
echo "Error!";
echo $e->getMessage() . "<br>";
echo 'Last response: ' . $client->__getLastResponse();
}
When I try to read from a function returning a list array or map array I have an error, can anyone help me? This is my code:
<?php
$serverAddress = "YOUR_SERVER_IP";
$serviceUrl = "http://127.0.0.1/soap-live/";
$wsdlUrl = $serviceUrl . 'wsdl/';
$clientParams = array(
'login' => 'admin',
'password' => 'paris',
'location' => $serviceUrl,
'trace' => true,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
);
$client = new SoapClient($wsdlUrl, $clientParams);
echo "===== Get_api_version( ) =====<br/>\n";
$response = $client->Get_input_info(1);
echo $response->return . "<br/>\n";
?>
Best Regards.
I have written a script that should connect to a secure web service (ws-security). However, when running the script, I'm getting this error:
Error: SOAP-ERROR: Encoding: object has no 'createLead' property
I'm using this code:
<?php
$wsdl = "http://localhost/test/wsdl-src/CRMLeadService.wsdl";
$momurl = "https://integrationdev.momentum.co.za/sales/CRMService/CRMLeadService_v1_0/";
echo "Post to URL: {$momurl}\n";
$username = '817221';
$password = '1234';
//Perform Request
$client = new SoapClient ($wsdl, array('loacation' => $momurl));
$security = array('UsernameToken' => array(
'Username'=>"$username",
'Password'=>"$password"
));
$header = new SoapHeader('wsse','Security',$security, false);
$client->__setSoapHeaders($header);
print_r($client);
echo "<br />";
print_r( $client->__getFunctions() ); //Available Function
$params = array(
'LeadSourceId' => '23627e70-a29e-e211-b8a8-005056b81ebe',
'AffiliateLeadReference' => '5465546hdfh5sggd52',
'Title' => '852800018',
'Initials' => 'MD',
'PreferredName' => 'Marius',
'FirstName' => 'Marius',
'LastName' => 'Drew',
'PreferredCorrespondenceLanguage' => '852800001',
'PreferredCommunicationMethod' => '852800000',
'Campaign' => '',
'HomePhoneNumber' => '0723621762',
'BusinessPhoneNumber' => '0723621762',
'MobilePhoneNumber' => '0723621762',
'EmailAddress' => 'mdrew#gmail.com',
'Notes' => 'IMU',
'ProductCategories' => array('Code' => 'd000083d-229c-e211-b8a8-005056b81ebe')
);
print_r($params);
try {
echo $result = $client->__soapCall('createLead',array('parameters'=>$params));
} catch (Exception $e) {
$msgs = $e->getMessage();
echo "Error: $msgs";
}
?>
The WSDL and XSD files can be downloaded here:
http://sdrv.ms/16KC8o4
Any help would be appreciated. Thanks!
Why i am getting the following
error
Warning: SoapClient::__doRequest(): Unable to find the wrapper "https"
- did you forget to enable it when you configured PHP
What is my mistake?
My code is following
$config = parse_ini_file('ebay.ini', true);
$site = $config['settings']['site'];
$compatibilityLevel = $config['settings']['compatibilityLevel'];
$dev = $config[$site]['devId'];
$app = $config[$site]['appId'];
$cert = $config[$site]['cert'];
$token = $config[$site]['authToken'];
$location = $config[$site]['gatewaySOAP'];
// Create and configure session
$session = new eBaySession($dev, $app, $cert);
$session->token = $token;
$session->site = 203; // 0 = US;
$session->location = $location;
// Make an AddItem API call and print Listing Fee and ItemID
try {
$client = new eBaySOAP($session);
$PrimaryCategory = array('CategoryID' => 357);
$Item = array('ListingType' => 'Chinese',
'Currency' => 'INR',
'Country' => 'US',
'PaymentMethods' => 'PaymentSeeDescription',
'RegionID' => 0,
'ListingDuration' => 'Days_3',
'Title' => 'The new item',
'Description' => "It's a great new item",
'Location' => "San Jose, CA",
'Quantity' => 1,
'StartPrice' => 24.99,
'PrimaryCategory' => $PrimaryCategory,
);
$params = array('Version' => $compatibilityLevel, 'Item' => $Item);
$results = $client->AddItem($params);
// The $results->Fees['ListingFee'] syntax is a result of SOAP classmapping
print "Listing fee is: " . $results->Fees['ListingFee'] . " <br> \n";
print "Listed Item ID: " . $results->ItemID . " <br> \n";
print "Item was listed for the user associated with the auth token code herer>\n";`enter code here`
} catch (SOAPFault $f) {
print $f; // error handling
}
Thanks in advance
Murali
You have to add (or uncomment it) extension=php_openssl.dll; to your php.ini file.
i'm trying to connect my page to a webservice soap. My hosting doesn't support soap so SoapClient isn't recognized. I have a working example to connect to that ws but uses SoapClient. This is:
$params = array('location'=>"www.wssite.com/test.php",
'trace'=>1,
'exceptions'=>1);
$client = new SoapClient("url_of_wsdl",$params);
var_dump($client->__getFunctions());
var_dump($client->__getTypes());
$pars = array('ipcInvocationName' => 'wsinvokeservice',
'ipcMethodNamespace' => 'svcmsgxml.bldximsgin',
'ttIn' => array(
'ttInRow' => array( array('ParPos' => '0','ParNam' => 'MethodName',
'ParVal' => POST),
array('ParPos' => '1','ParNam' => 'XMLDocumentIn',
'ParVal' => 'LoginXmlValue'))),
'ttOut' => array('ttOutRow' => array(array('ParPos' => '0',
'ParNam' => 'ContentType','ParVal' => ''),array('ParPos' => '1',
'ParNam' => 'Result','ParVal' => ''),
array('ParPos' => '2','ParNam' => 'XMLDocumentOut','ParVal' => '')));
$return = $client->wssigateway($pars);
It works good!
I used NuSoap in this way:
require_once 'soap/nusoap.php';
$wsdl = 'url_of_wsdl';
$client = new soapclient($wsdl,true);
$err = $client -> getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
exit();
}
$pars = array()//the same as above
$result = $client -> call('wssigateway',$pars);
The script works for too much time and does get me nothing.. why? can someone help me?
Try $client = new nusoap_client($wsdl,true);
instead of $client = new soapclient($wsdl,true);