WSO2AS Soapcall of service returns null - php

I'm developing a web-app, which needs data from a database.
For the communication with the db I use WSO2AS.
I made a database and linked that to the data service created, when i test the service in the admin panel of WSO2, I get the data needed from the database.
The data service I created is called TestService.
Now I want to have the same response in my php template as well, using this code.
<?php
try {
$client = new SoapClient('http://192.168.178.12:9763/services/TestService?wsdl');
$result = $client->__soapCall('greet');
printf("Result = %s\r\n", $result->return);
} catch (Exception $e) {
printf("Message = %s\r\n",$e->__toString());
}
?>
But this gives NULL, when I try to dump the $result.
When I try to execute an example WSO2 created, I do get the right result. While the soapcall code is the same, only the service name is different.
<?php
try {
$client = new SoapClient('http://192.168.178.12:9763/services/HelloService?wsdl');
$result = $client->__soapCall('greet', array(array('name' => 'Sam')));
printf("Result = %s\r\n", $result->return);
} catch (Exception $e) {
printf("Message = %s\r\n",$e->__toString());
}
?>
This code returns "Hello Sam !!!".
So I wonder what I did wrong, I personally think I made a mistake in implementing the service itself, but can't find it.
If any more information is needed feel free to ask, hope someone can help me with this.
Thanks in advance!

Apparently you need to have arguments in your soapcall.
After calling this __soapCall('greet', array());
It gave the proper response.

Related

How to post a new answer to a question with Google My business API in PHP

We have a Google My business account that manage multiple locations. I want to create an interface for answering questions. My problem is that I can't find how to retreive the Author object for the current location.
I tried creating a new Google_Service_MyBusiness_Author object and submitting it but it doesn't seems to work. I'm using MyBusiness API 4.5
$author = new Google_Service_MyBusiness_Author();
$author->setDisplayName('location display name');
$author->setProfilePhotoUrl('someurl.jpg');
$author->setType('MERCHANT');
$answer = new Google_Service_MyBusiness_Answer();
$answer->setText($_POST['answerReplyText']);
$answer->setAuthor($author);
$postBody = new Google_Service_MyBusiness_UpsertAnswerRequest();
$postBody->setAnswer($answer);
try {
$mybusinessService->accounts_locations_questions_answers->upsert($_POST['question_name'],$postBody);
}
catch(Exception $e) {
var_dump($e);
}
I get the 'Request contains an invalid argument' exception. I am doing this the right way ? What should I do to make my answer valid ?
Please try the following by removing the output only fields:
// $author = new Google_Service_MyBusiness_Author();
// $author->setDisplayName('location display name');
// $author->setProfilePhotoUrl('someurl.jpg');
// $author->setType('MERCHANT');
$answer = new Google_Service_MyBusiness_Answer();
$answer->setText($_POST['answerReplyText']);
// $answer->setAuthor($author);
$postBody = new Google_Service_MyBusiness_UpsertAnswerRequest();
$postBody->setAnswer($answer);
try {
$mybusinessService->accounts_locations_questions_answers->upsert($_POST['question_name'],$postBody);
}
catch(Exception $e) {
var_dump($e);
}
This works for me quite well. Hope this will help you too.

soap example successful request response using php curl for Income tax Return efiling(india)

I have been trying this for many days but not succeeded. How to make a successful WSDL Soap request to ITR web site.
The sample soap url: https://incometaxindiaefiling.gov.in/e-FilingSecWS/ditsecws/BulkItrService?wsdl
and
The manual which I have refered is: https://incometaxindiaefiling.gov.in/eFiling/Portal/StaticPDF/Secure_WebServices_UserManual.pdf
If any one has any idea please let me know the Steps/Tutorial to successfully make a soap call using PHP apache2 Server, thank you in advance.
You can get a sample code here ..i am trying this.
<?php
ini_set('display_errors',1);
error_reporting(1);
//var_dump($xml);
include('includexml.php');echo '<pre>';
$soapUrl = "https://incometaxindiaefiling.gov.in/e-FilingSecWS/ditsecws/BulkItrService?wsdl";
//Create the client object
$soapclient = new SoapClient("$soapUrl",array('soap_version' => SOAP_1_1));
try {
print($soapclient->uploadBulkItr($includexml));
} catch (SoapFault $exception) {
echo $exception;
}
$res=$soapclient->__getFunctions();
print_r($res);
die;

Does Laravel 5.3019 database Transaction method work?

I've use Larvel 5.0 with Database transaction all the method in my previous web application it work as well and we are really love it because this application help me much more than our estimated
so we have create another webs application by using this newest version of this framework and used the same Database structure but finaly it would not work for me and another one to.
I have as more peoples and post on some toturial website for asking any belp but not yet get any solution so I record this video for sure about this case.
Issue: My issue I've disabled (//commit()) method all data still can insert into Database.
final function Add()
{
if ($this->request->isMethod('post')) {
//No you will see this method use with Try Catch and testing again
//DB::beginTransaction(); // Ihave testing with outside of try and inside again
Try{
DB::beginTransaction();
$cats = new Cat();
$catD = new CategoryDescriptions();
$cats->parent_id = $this->request->input('category_id');
$cats->status = ($this->request->input('status')) ? $this->request->input('status') : 0;
if (($res['result'] = $cats->save())== true) {
$catD->category_id = $cats->id;
$catD->language_id = 1;
$catD->name = $this->request->input('en_name');
if (($res['result'] = $catD->save()) === true) {
$catD2 = new CategoryDescriptions();
$catD2->category_id = $cats->id;
$catD2->language_id = 2;
$catD2->name = $this->request->input('kh_name');
$res['result'] = $catD2->save();
}
}
if(!empty($res)) {
//DB::commit();
}
return [$res,($res['result'] = $catD->save())];
}catch(\Exception $e){ // I have already try to use Exception $e without backslash
DB::rollback();
}
}
$cat = Cat::with(['CategoryDescriptions', 'children'])->where('status', 1)->get();
return view('admin.categories.add', ['cat' => $cat]);
}
You can check on my video to see that .
Check on my video
I don't know why your code did not work. But you can try with this code I think it's will work. Laravel transaction documentation
try{
DB::transaction(function)use(/*your variables*/){
// your code
});
}catch(\PDOException $exception){
//debug
}
If any exception occurs it will automatically rollback. If you want manual rollback then inside transaction you can throw a manual exception based on your logic.

Get bad WSDL from SoapFault?

I'm connecting to a 3rd party service with SoapClient. Most of the time it works fine, but every once in awhile, maybe once out of every 100-150 calls, I get the error
Soap Failed: SOAP-ERROR: Parsing Schema: unexpected in complexType
My code is in a try/catch with a retry, and it will work on the next round through. But I'd like to examine the WSDL to find out why that fails, partly for my own curiosity, and in case I need to pass it along to the company I'm connecting to. Can I get that information from the SoapFault? Or would I have to call the URL to get the string? I'm afraid if I get the WSDL after the fact, it may already be fixed.
$pass = FALSE;
$this->soap = NULL;
$this->session = NULL;
do {
try {
Doc::i("Starting session");
$this->soap = new SoapClient($this->wsdl_url, ['trace' => 1]);
$pass = TRUE;
} catch (\SoapFault $e) {
Doc::e('Soap Failed: ' . $e->getMessage());
if(str_contains($e->getMessage(),'Parsing Schema') && !empty($e->detail)) {
Doc::e($e->detail); // Something new I'm trying to see if it helps
}
} catch (FatalErrorException $e) {
Doc::e("Soap failed really bad: " . $e->getMessage());
} catch (\Exception $e) {
Doc::e("Soap failed bad: " . $e->getMessage());
}
} while (!$pass);
You should be able to use $this->soap->__getLastResponse() since you are passing 'trace' => 1 option to SoapClient.
You might also consider logging $this->soap->__getLastRequest as well as the headers versions of both of these to ensure you're capturing as much information as possible at run-time.
Refer to the SoapClient method list for the possible options. Just remember the trick here is the trace option: without that, these will not return anything useful!

Handling $resource request from PHP backend using SLIM

I'm having problems accessing my PHP backend from AngularJS.
I have followed:
http://coenraets.org/blog/2012/02/sample-application-with-angular-js/
Routing with AngularJS and Slim PHP
Some other's too but those are similar. I've tackled the problem for a few days now and still can't get it working.
First way to call my php script
app.controller('PhoneDetailCtrl',function($scope, $modal, $resource) {
var request_Id = 1;
var Request = $resource('http://mobiiltelefonid24.ee/api/kasutatud_telefonid/'+request_Id);
$scope.request = Request.get();} //this way I get code 200 but 119 empty chars.. So I figure routing should be correct?
Second way I tried
app.controller('PhoneDetailCtrl',function($scope, $modal, Service) {
$scope.request = Service.get({id:1});} //this gives me code 200 but 119 empty chars...
app.service('Service', function ($resource) {
return $resource('api/kasutatud_telefonid/:id', {}, {
update: {method:'PUT'}
});});
PHP code (using mysql db)
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/', 'getPopularPhones');
$app->get('/uued_telefonid','getNewPhones');
$app->get('/kasutatud_telefonid','getUsedPhones');
$app->get('/uued_telefonid/:id', 'getPhoneDesc');
$app->get('/kasutatud_telefonid/:id', 'getPhoneDesc');
$app->run();
/*Other get methods are exactly the same but with different name*/
function getPhoneDesc($id) {
$sql = "SELECT * FROM Phone";
try {
$db = getConnection();
$stmt = $db->query($sql);
$wines = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
echo json_encode($wines);
} catch(PDOException $e) {
echo '{"error":{"text":'. $e->getMessage() .'}}';
}
}
getConnection() is implemented as shown in wine app tutorial. There is one row in db that has 21 colums so it should return something. Also tried to pass string $wine="teststring" but that also arrived as jibbrjabbre.
Is routing wrong or is there problems with querying from db? (I can query just fine from phpMyAdmin). Out of ideas...
Solved! Slim was falsely configured and meekroDB worked just fine (Thanks mainguy). On top of that there were some issues on webhosts side.

Categories