PHP Fatal error:Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery - rets

I am using the PHRETS PHP library to fetch the RETS data from the rets API. I have and issue with getting the Data. It's giving "PHP Fatal error: Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery. Reference ID: fc63ca3e-c8a8-44cf-a0ce-4c729ce91fcc' in /XXXX/vendor/troydavisson/phrets/src/Session.php:379". Please help to solve this Error. My Code is:
<pre><code>
date_default_timezone_set('America/New_York');
require_once("vendor/autoload.php");
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://sef.rets.interealty.com/Login.asmx/Login');
$config->setUsername('XXXX');
$config->setPassword('XXXX');
// optional. value shown below are the defaults used when not overridden
$config->setRetsVersion('1.7.2'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('RETS-Connector/1.2');
$config->setUserAgentPassword('123456'); // string password, if given
$config->setOption('use_post_method', false); // boolean
$config->setOption('disable_follow_location', false); // boolean
$session = new \PHRETS\Session($config);
$connect = $session->Login();
$system = $session->GetSystemMetadata();
//var_dump($system);
$resources = $system->getResources();
$classes = $resources->first()->getClasses();
//var_dump($classes);
$classes = $session->GetClassesMetadata('Property');
//var_dump($classes->first());
$results = $session->Search("Property", "2", "*", ['Limit' => 3, 'Select' => '922']);
foreach ($results as $r) {
var_dump($r);
}
</pre></code>
And It returning error :
[11-Mar-2017 06:32:59 America/New_York] PHP Fatal error: Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery. Reference ID: fc63ca3e-c8a8-44cf-a0ce-4c729ce91fcc' in /home2/XXXX/vendor/troydavisson/phrets/src/Session.php:379
Stack trace:
0 /home2/XXXX/vendor/troydavisson/phrets/src/Session.php(297): PHRETS\Session->request('Search', Array)
1 /home2/XXXX/index.php(34): PHRETS\Session->Search('Property', '2', '*', Array)
2 {main}
thrown in /home2/XXXX/vendor/troydavisson/phrets/src/Session.php on line 379

Performing searches through RETS using an asterisk is something only a few servers support. In every other case, a normal query needs to be given which is surrounded with parentheses.
You can see this tutorial for a brief introduction in the query structure used by RETS:
https://www.flexmls.com/developers/rets/tutorials/dmql-tutorial/
For that particular server, one example to get you going could be:
(sysid=0+)

Related

Trying to get property 'menu_display_categories' of non-object

I'm having issues with this... I'm trying to install "downGrade - Single Vendor Digital Products Marketplace
"
https://codecanyon.net/item/downgrade-single-vendor-digital-products-marketplace/28803672?gclid=Cj0KCQjw2MWVBhCQARIsAIjbwoOi08ajt47xsPKUsGZ7V7mr7KD5W_CwaQS-BfF1tbP1OE0-LpNdR6caAmCbEALw_wcB
I'm getting this error code and I'd like to receive your help, thank you.
$admin = Members::adminData();
View::share('admin', $admin);
$allsettings = Settings::allSettings();
View::share('allsettings', $allsettings);
$allcountry = Settings::allCountry();
View::share('allcountry', $allcountry);
$country['country'] = Settings::allCountry();
View::share('country', $country);
$demo_mode = 'off'; // on
View::share('demo_mode', $demo_mode);
$main_menu['category'] = Category::mainmenuCategoryData($allsettings->menu_display_categories,$allsettings->menu_categories_order);
View::share('main_menu', $main_menu);
$footer_menu['category'] = Category::mainmenuCategoryData($allsettings->footer_menu_display_categories,$allsettings->footer_menu_categories_order);
View::share('footer_menu', $footer_menu);
$footerpages['pages'] = Pages::footermenuData();
View::share('footerpages', $footerpages);
$languages['view'] = Languages::allLanguage();
View::share('languages', $languages);
if(!empty(Cookie::get('translate')))
{
The reason why you getting the error is that the $allsetting is null.
$main_menu['category'] = Category::mainmenuCategoryData($allsettings->menu_display_categories,$allsettings->menu_categories_order);
The $allsettings gets the value from the setting table from the database where you can easily see the value menu_display_categories is nulled.
//Nulled here ---> $allsettings->menu_display_categories
Solution: Enter the values in all columns inside the setting table.

how to define BusinessNetworkConnection in hyperledger-composer transaction processor?

In my hyperledger-composer app, I have a transaction processor:
async function doSomething(transaction) {
//some code
// the following line results in error message:
const connection = new BusinessNetworkConnection();
await connection.connect('admin#tmy-network');
const result = await connection.query(selectPatientByEmail, { inputValue: email });
//some more code
}
However, the line
const connection = new BusinessNetworkConnection();
causes the following error messsage:
ReferenceError: BusinessNetworkConnection is not defined
How can I define the BusinessNetworkConnection?
*******************************UPDATE**************************************
Following the comment by Paul O'Mahony, I used the following line of code in my transaction processor function (in order to get the patient with the email address 'adam#gmail.com'):
let result = await query('selectPatientByEmail', {
"email": "adam#gmail.com"
});
The query is defined in the queries.qry file as follows:
query selectPatientByEmail {
description: "Select the patient with the given email address"
statement:
SELECT org.comp.app.Patient
WHERE (email == _$email)
}
However, the query returns "undefined" (i.e. variable "result" is undefined) .
What for god's sake is wrong with the code? I just can't see what might be the causing this behaviour.
***************************Update2*****************************************
I have to correct myself ... the query returns something ... but when I want to access the id of the returned patient, this is not possible. That is,
result.id is "undefined"
How can I access the id of the patient returned?
this is because you are (above) writing client code inside a native transaction function - you don't need to set these. Transaction processor functions are automatically invoked by the runtime when transactions are submitted (eg using the BusinessNetworkConnection API under the covers, but it is already part of the transaction - you don't need to specify) . See https://hyperledger.github.io/composer/latest/reference/js_scripts for more info - and the sample networks for common use cases and examples -> https://github.com/hyperledger/composer-sample-networks/tree/master/packages/

Exchange EWS SearchMailboxes invalid child element error

I have a strange error. When i try to do a SearchMailboxes, I get this error:
Unhandled Exception: Microsoft.Exchange.WebServices.Data.ServiceResponseException: The request "://schemas.microsoft.com/exchange/services/2006/types" has invalid child element 'ExtendedAttributes'
The problem is that i get this error in some pc's. With fiddler I could see that my pc sends a request without the node ExtendedAttributes and it works.
This is the ExtendedAttributes node that produces the error.
The code:
List<MailboxSearchScope> scopeList = new List<MailboxSearchScope>();
foreach (SearchableMailbox mb in searchableMailboxes)
{
MailboxSearchScope scope = new MailboxSearchScope(mb.ReferenceId, MailboxSearchLocation.All);
scopeList.Add(scope);
}
MailboxQuery query = new MailboxQuery(searchQuery, scopeList.ToArray());
MailboxQuery[] mbQueryList = new MailboxQuery[] { query };
SearchMailboxesParameters p = new SearchMailboxesParameters
{
SearchQueries = mbQueryList,
ResultType = SearchResultType.PreviewOnly
};
ServiceResponseCollection<SearchMailboxesResponse> res = _service.SearchMailboxes(p);
ExtendedAttributes is a new element that was introduced in Exchange 2013 SP1 and is intended for internal use only.
http://msdn.microsoft.com/en-us/library/office/dn627392(v=exchg.150).aspx
I don't see in your code where you are trying to use this element so I would suggest that you specify ExchangeVersion.Exchange2013 when you are instantiating your ExchangeService object.

servicestack - caching a service response using redis

I have a servicestack service which when called via the browser (restful) Url ex:http://localhost:1616/myproducts, it works fine.
The service method has RedisCaching enabled. So first time it hits the data repository and caches it for subsequent use.
My problem is when I try calling it from a c# client via Soap12ServiceClient. It returns the below error:
Error in line 1 position 183. Expecting element '<target response>'
from namespace 'http://schemas.datacontract.org/2004/07/<target namespace>'..
Encountered 'Element' with name 'base64Binary',
namespace 'http://schemas.microsoft.com/2003/10/Serialization/'.
Below is my Client code:
var endpointURI = "http://mydevelopmentapi.serverhostingservices.com:1616/";
using (IServiceClient client = new Soap12ServiceClient(endpointURI))
{
var request = new ProductRequest { Param1 = "xy23432"};
client.Send<ProductResponse>(request);
}
It seems that the soapwsdl used is giving the problem, but I appear to have used the defaults as generated by servicestack..
Any help will be much appreciated.
Update
I was able over come this error by changing the cache code at the service end:
Code that returned error at client end:
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Code that works now:
var result = this.CacheClient.Get<ProductResponse>(cacheKey);
if (result == null)
{
this.CacheClient.Set<ProductResponse>(cacheKey, productResult);
result = productResult;
}
return result;
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
From what I can tell, the ToOptimizedResultUsingCache is trying to pull a specific format (xml, html, json, etc) out of the cache based on the RequestContext's ResponseContentType (see code here and here). When using the Soap12ServiceClient the ResponseContentType is text/html (not sure if this is correct/intentional within ServiceStack). So what ToOptimizedResultUsingCache is pulling out of the cache is a string of html. The html string is being returned to the Soap12ServiceClient and causing an exception.
By pulling directly out of the cache you are bypassing ToOptimizedResultUsingCache's 'format check' and returning something the Soap12ServiceClient can handle.
** If you are using Redis and creating your key with UrnId.Create method you should see a key like urn:ProductResponse:{yourkey}.html
Thanks for your response paaschpa.
I revisited the code and I was able to fix it. Since your response gave me the direction, I have accepted your answer. Below is my fix.
I moved the return statement from RequestContext to the response DTO.
Code which throws error when used via c# client (code was returning entire requestcontext):
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Fixed Code (return moved to response DTO):
RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() => {
return new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
}
});

Kohana 3.2 Validation_Exception will not support errors()

I am trying to add the error messages to my validation object.
It says that errors is not a method of Validation_Exception. That I know... The thing is that I though the $e variable would be the instance of the Validation Class in the model. My question is how can attach the error messages?
Error:
ErrorException [ Fatal Error ]: Call to undefined method Validation_Exception::errors()
Controller:
208 // redirect to the user account
209 $this->request->redirect('user/profile');
210 } catch (Validation_Exception $e) {
211 // Get errors for display in view
212 // Note how the first param is the path to the message file (e.g. /messages/register.php)
213 $errors = $e->errors('register/user');
214 // Move external errors to main array, for post helper compatibility
215 $errors = array_merge($errors, (isset($errors['_external']) ? $errors['_external'] : array()));
216 $view->set('errors', $errors);
217 // Pass on the old form values
218 $_POST['password'] = $_POST['password_confirm'] = '';
Model:
$validation = Validation::factory($fields)
->rules('username', $this->_rules['username'])
->rule('username', array($this, 'username_available'), array(':validation', ':field'))
->rules('email', $this->_rules['email'])
->rule('email', array($this, 'email_available'), array(':validation', ':field'))
->rules('password', $this->_rules['password'])
->rules('password_confirm', $this->_rules['password_confirm']);
//->labels($_labels);
if (Kohana::config('useradmin')->activation_code) {
$validation->rule('activation_code', array($this, 'check_activation_code'), array(':validation', ':field'));
}
if(!$validation->check())
{
throw new Validation_Exception($validation, __('Your registering information is not valid.'));
}
I really don't see why this error is accuring.
You have basically answered your own question - Validation_Exception doesn't have errors method. You need to call it from Validation object instead.

Resources