Getting my SOAP application to work - php

I am making a start on SOAP but can't get past the first hurdle of authenticating myself...
Here is my code...
$login = array(
'loginWebRequest' => array(
'Username' => 'myuser',
'Password' => 'mypass'
)
);
$url = 'https://qa-api.ukmail.com/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl';
$client = new SoapClient($url);
$result = $client->Login('Login',$login);
print_r($result);
I hope someone can see a mistake I have obviously made!
print_r($client->__getFunctions());
tells me this...
Array
(
[0] => LoginResponse Login(Login $parameters)
[1] => LogoutResponse Logout(Logout $parameters)
)
Thanks in advance
Paul

Try this:
$options = array(
"trace" => 1,
"exception" => 1
);
$login = array(
'loginWebRequest' => array(
'Username' => 'myuser',
'Password' => 'mypass'
)
);
$url = 'https://qa-api.ukmail.com/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl';
$client = new SoapClient($url,$options);
$result = $client->call('Login',$login);
echo "<pre>";
print_r($client->__getLastRequest());
echo "<hr />";
print_r($result);
I recomend the use of soapui before any code, is importante to test de wsdl functions and permissions. In SOAPUI you can do a call for login function and it is more fast and easy to check for example login and password information.

Related

SOAP java.lang.NullPointerException Error

I made a research on web but I couldn't find the exact answer for my question. I am trying to make a request to a SOAP service. I can get a proper response when I try with SOAPUI but I can't get anything when I try it with PHP.
Here is a screenshot of SOAPUI: (Backup URL: http://i.hizliresim.com/qGaOOd.png)
Here is my PHP code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$wsdl = "http://www.estes-express.com/shipmenttracking/services/ShipmentTrackingService?wsdl";
$options = array(
'auth' => array(
'user' => 'myuser',
'password' => 'mypass'
)
);
$request = array(
'search' => array(
'requestID' => '0841824923',
'pro' => '0841824923'
)
);
$client = new SoapClient($wsdl, $options);
echo '<pre>'.print_r($client,true).'</pre>';
try{
$response = $client->__soapCall('trackShipments', array($request));
print_r($response);
} catch(SoapFault $ex){
echo $ex->getMessage();
}
print "\n";
When I run this script, it returns this error: "java.lang.NullPointerException"
Any solutions? Thanks in advance.

SOAP Client error list array read

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.

Session not brougt at codeigniter curl request

I'm create a remote access using codeigniter curl library from here https://github.com/philsturgeon/codeigniter-curl , then using this code below to login, then I get good respons that I've logged in.
$this->load->library('curl');
$opt = array(
'COOKIEJAR' => 'curl_sess/cookie.txt',
'COOKIEFILE' => 'curl_sess/cookie.txt',
);
$array = array(
'email' => 'user#example.com',
'password' => 'somepassword'
);
echo $this->curl->simple_post('http://remoteweb.com/cek_login', $array, $opt);
Then I want to create another request that need logged in status, like :
$array = array();
echo $this->curl->simple_get('http://remoteweb.com/get_datadeposit', $array);
but I get nothing, because my login session at first request not brought in second request.How to achieve this or I missing something ... ?
Try
$this->load->library('curl');
$opt = array(
CURLOPT_COOKIEJAR => 'curl_sess/cookie.txt',
CURLOPT_RETURNTRANSFER => true
);
$array = array(
'email' => 'user#example.com',
'password' => 'somepassword'
);
echo $this->curl->simple_post('http://remoteweb.com/cek_login', $array, $opt);

NuSoap doesn't work

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);

Zend_Service_Twitter Oauth Incorrect Signature

I have sucessfully connected to twitter using Zend_Oauth_Consumer and got an access token, however when i try to use this access token i am getting an error.
This is the code:
$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();
This outputs:
Zend_Rest_Client_Result Object (
[_sxml:protected] => SimpleXMLElement Object
(
[request] => /1/account/verify_credentials.xml
[error] => Incorrect signature
)
[_errstr:protected] => )
I assume the code is actually correct, its hard to tell as the examples on the ZF site are incomplete.
FWIW i am using Zend Framework 1.10.8
some fields were missing:
$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();
should be:
$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token,
'consumerKey' => YOUR_APP_CONSUMER_KEY,
'consumerSecret' => YOUR_APP_CONSUMER_SECRET,
'callbackUrl' => YOUR_CALLBACK_URL
));
$response = $twitter->account->verifyCredentials();
To confirm, for a valid signature you need all the same fields that you are using with Zend_Oauth_Consumer

Categories