I created web service using asp.net framework 4 :
[WebMethod]
public DataSet GetMembers(string memberId, string thirdName)
{
string connStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
SqlConnection cn = new SqlConnection(connStr);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = new SqlCommand(#"SELECT MemberMaster.MemberId,MemberMaster.FirstName,MemberMaster.SecondName,MemberMaster.ThirdName,MemberMaster.CivilNo,MemberMaster.DateOfBirth,MemberSubcription.MemberId
FROM MemberMaster inner join MemberSubcription on MemberMaster.MemberId=MemberSubcription.MemberId
WHERE MemberMaster.MemberId=#MemberId and MemberMaster.ThirdName=#ThirdName", cn);
da.SelectCommand.Parameters.Add("#MemberId", SqlDbType.NVarChar).Value = memberId;
da.SelectCommand.Parameters.Add("#ThirdName", SqlDbType.NVarChar).Value = thirdName;
ds.Clear();
da.Fill(ds);
return ds;
}
it work good in localhost but when i call it in the php :
<?php
$wsdlUrl = "http://xxxx/WS/WebService.asmx?WSDL";
$client = new soapclient($wsdlUrl);
$params = array('memberId' => 'W1100045','thirdName' => 'Ali');
$result = $client->GetMembers($params);
$echoText = '';
if (is_null($result->GetMembersResult))
{
echo "no result";
}
else
{
echo $result->GetMembersResult;
}
?>
this error appear :
Catchable fatal error: Object of class stdClass could not be converted to string on line 23
what is the problem and how can i solve this problem ?
Related
I tried to get data using Microsoft Graph beta api
"require": {
"microsoft/microsoft-graph-beta": "^2.0.0-RC13",
"microsoft/microsoft-graph-core": "#RC"
}
//code 1
''''
$tokenRequestContext = new ClientCredentialContext(
',//tenantId
'',//clientId
''//clientSecret
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);
try {
$response = $betaGraphServiceClient->usersById('[userPrincipalName]')->get();
$user = $response->wait();
echo "Hello, I am {$user->getGivenName()}";
} catch (ApiException $ex) {
echo $ex->getMessage();
}
''''
//code 2
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
use Microsoft\Graph\Beta\GraphRequestAdapter;
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Kiota\Abstractions\ApiException;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
use Microsoft\Kiota\Authentication\PhpLeagueAuthenticationProvider;
use Microsoft\Graph\Beta\Generated\Teams\Item\Schedule\Shifts\ShiftsRequestBuilderGetRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Teams\Item\Schedule\Shifts\ShiftsRequestBuilderGetQueryParameters;
$tokenRequestContext = new ClientCredentialContext(
'',//tenantId
'',//clientId
''//clientSecret
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);
$requestConfiguration = new ShiftsRequestBuilderGetRequestConfiguration();
$queryParameters = new ShiftsRequestBuilderGetQueryParameters();
$queryParameters->filter = "startDateTime ge 2023-01-05T06:00:00.000Z and sharedShift/endDateTime le 2023-01-06T06:00:00.000Z";
$requestConfiguration->queryParameters = $queryParameters;
$requestResult = $betaGraphServiceClient->teamsById('teamId')->schedule()->shifts()->get($requestConfiguration);
''''
But returns the same error results
Fatal error: Declaration of Microsoft\Graph\Beta\Generated\Models\ODataErrors\ODataError::getAdditionalData(): ?array must be compatible with Microsoft\Kiota\Abstractions\Serialization\AdditionalDataHolder::getAdditionalData(): array in D:...\vendor\microsoft\microsoft-graph-beta\src\Generated\Models\ODataErrors\ODataError.php on line 43
I want to create an invoice to third party invoice software i.e. twinfield from API. I give all the param according to its library and doc and call from API but it will give error.
{
"success": false,
"error": "Item code not found., The description of an item line cannot be adjusted." }
The API is php-twinfield.
The code is given below.
public function saveInvoice($values)
{
try
{
$user = $values['user'];
$password = $values['password'];
$organization = $values['organisation'];
$officecode = $values['officecode'];
$connection = new \PhpTwinfield\Secure\WebservicesAuthentication($user, $password, $organization);
$customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($connection);
$office = Office::fromCode($officecode);
$customer = $customerApiConnector->get('1008',$office);
$InvoiceApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceApiConnector($connection);
//class invoiceline object
$line = new \PhpTwinfield\InvoiceLine();
$line
->setArticle(2)
->setQuantity(2)
->setValueExcl(100)
->setUnits(1)
->setVatCode('VH')
->setUnitsPriceExcl(100)
->setDim1(8020)
->setDescription("Testinvoice anand")
->setAllowDiscountOrPremium(false);
//class invoice object
$invoice = new \PhpTwinfield\Invoice();
$invoice
->setCustomer($customer)
->setBank('BNK')
->setDueDate(\Carbon\Carbon::now()->addMonth())
->setPeriod('2018/12')
->setCurrency('EUR')
->setStatus('concept')
->setInvoiceDate('20180606')
->addLine($line)
->setPaymentMethod('cash')
->setInvoiceType('FACTUUR');
$result = $InvoiceApiConnector->send($invoice);
print_r($result);
//$jsonResponse = JsonResponse::success($result);
}
catch (SoapFault $e)
{
$jsonResponse = empty($e->getMessage()) ? JsonResponse::error(class_basename($e)) : JsonResponse::error($e->getMessage());
}
//return $jsonResponse;
}
if change in this line $line->setArticle(0) the error is like that.
{
"success": false,
"error": "ResponseException" }
I am trying to add members in a cohort but whenever i call the function this is the response i get.I am using drupal rest to make the api call.
{
"exception": "dml_write_exception",
"errorcode": "dmlwriteexception",
"message": "Error writing to database",
"debuginfo": "Column 'role_id' cannot be null\nINSERT INTO mdl_cohort_members (cohortid,userid,timeadded,role_id) VALUES(?,?,?,?)\n[array (\n 0 => '3',\n 1 => '52367',\n 2 => 1460546128,\n 3 => NULL,\n)]"
}
Can somebody direct me towards the solution.
{
$fname = 'core_cohort_add_cohort_members';
/// Paramètres
$member = new stdClass();
$member->cohorttype['type']='id';
$member->cohorttype['value']='3';
$member->usertype['type']='id';
$member->usertype['value']='5';
$members = array($member);
$par = array('members' => $members);
$rest_format = 'json';
$Serve_Url = 'http://dev-lms.teletaleem.net' . '/webservice/rest/server.php'. '?wstoken=' . '7882bb500bcefcd8778de64b8e79a19a' .'&wsfunction='. $fname;
require_once('curl.inc');
$Rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';
$curl = new curl;
//if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2
$rep = $curl->post($Serve_Url.$Rest_format, $par);
dpm($rep);
}
I am trying to use SoapClient in PHP to retrieve data from a WSDL. If I use hardcoded values, then it works with zero errors:
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = 'UsedCar';
$params2['ApplicationCategory'] = 'Consumer';
$params2['VersionDate'] = '2016';
$result2 = $client->GetMakes($params2);
I am getting the following error when I use variables or dynamic content:
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed
] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter
http://someURL/VehicleInformationService:VehicleClass
. The InnerException message was 'Invalid enum value 'UsedCars'
I have tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = $VehicleClass;
$params2['ApplicationCategory'] = $ApplicationCategory;
$params2['VersionDate'] = $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = (string) $obj->{'LoginResult'};
$params2['VehicleClass'] = (string) $VehicleClass;
$params2['ApplicationCategory'] = (string) $ApplicationCategory;
$params2['VersionDate'] = (string) $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried:
$SubmitData = new stdClass();
$SubmitData->AuthenticationKey = new SoapVar($obj->{'LoginResult'}, XSD_STRING);
$SubmitData->VehicleClass = new SoapVar($VehicleClass, XSD_STRING);
$SubmitData->ApplicationCategory = new SoapVar($ApplicationCategory, XSD_STRING);
$SubmitData->VersionDate = new SoapVar($VersionDate, XSD_STRING);
$result2 = $client->GetMakes($SubmitData);
Same error each time. I do not know how to get around "Invalid enum value" error
Thanks in advance
I'm currently working on a project with the MangoPay api (with PHP SDK) and I have some trouble with the PaymentDetails. The function below generate this key (when I call the MangoPay Create method on my PayIn object) :
payins_stdclass-direct_create
instead of :
payins_preauthorized-direct_create
The function I'm using :
<?php
private function createAuthorizationPayIn($authorization, $fees)
{
$payIn = new MangoPay\PayIn();
$payIn->CreditedWalletId = $this->adminWalletId;
$payIn->AuthorId = $this->adminUserId;
$payIn->PaymentType = "PREAUTHORIZED";
$PayIn->PaymentDetails = new MangoPay\PayInPaymentDetailsPreAuthorized();
$payIn->PaymentDetails->PreauthorizationId = $authorization->Id;
$payIn->DebitedFunds = new MangoPay\Money();
$payIn->DebitedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->DebitedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->CreditedFunds = new MangoPay\Money();
$payIn->CreditedFunds->Currency = $authorization->DebitedFunds->Currency;
$payIn->CreditedFunds->Amount = $authorization->DebitedFunds->Amount;
$payIn->Fees = $fees;
$payIn->ExecutionType = "DIRECT";
$payIn->ExecutionDetails = new MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->SecureMode = "DEFAULT";
$payIn->ExecutionDetails->SecureModeReturnURL = "https://website.com";
$payIn = $this->mangoPayApi->PayIns->Create($payIn);
$authorization->payinId = $payIn->Id;
$authorization = $this->mangoPayApi->CardPreAuthorizations->Update($authorization);
return $payIn;
}
How can I create the right PaymentDetails object to create a preAuthorized PayIn ?