static void Main(string[] args) { var loginUrl = "https://some.rets.server.com/rets/login"; var username = ""; var password = ""; var userAgent = ""; using (var retsSession = new RetsSession(loginUrl)) { var uri = new Uri(loginUrl); if (uri.Scheme == Uri.UriSchemeHttps) { // ssl certificate work around - https://groups.google.com/forum/#!searchin/librets/ssl%7Csort:relevance/librets/g62O8pxsAcg/AXzlKi133TUJ retsSession.SetModeFlags(RetsSession.MODE_NO_SSL_VERIFY); } if (!string.IsNullOrEmpty(userAgent)) { retsSession.SetUserAgent(userAgent); } retsSession.SetRetsVersion(RetsVersion.RETS_1_8_0); if (!retsSession.Login(username, password)) { throw new Exception("RETS login failed"); } var loginResponse = retsSession.GetLoginResponse(); // todo: inspect login response } }
/** * Create a RetsSession and populate it with all the known options. */ public RetsSession SessionFactory() { uint flags = 0; if (mRetsSession != null) { mRetsSession.Cleanup(); mRetsSession = null; } mRetsSession = new RetsSession(mUrl); mRetsSession.SetDefaultEncoding(mEncoding); if (mHttpLog.Length > 0) { mRetsSession.SetHttpLogName(mHttpLog); } mRetsSession.SetLogEverything(mLogEverything); mRetsSession.SetRetsVersion(mRetsVersion); mRetsSession.SetUserAgent(mUA); mRetsSession.SetUserAgentAuthType(mUAAuth); if (mUAPass.Length > 0) { mRetsSession.SetUserAgentPassword(mUAPass); } if (mEnableCacheing) { flags |= RetsSession.MODE_CACHE; } if (mNoSSLVerify) { flags |= RetsSession.MODE_NO_SSL_VERIFY; } if (mDisableStreaming) { /* * Caching is required in non-streaming mode. */ flags |= RetsSession.MODE_CACHE | RetsSession.MODE_NO_STREAM; } mRetsSession.SetModeFlags(flags); return(mRetsSession); }
/** * Create a RetsSession and populate it with all the known options. */ public RetsSession SessionFactory() { uint flags = 0; if (mRetsSession != null) { mRetsSession.Cleanup(); mRetsSession = null; } mRetsSession = new RetsSession(mUrl); mRetsSession.SetDefaultEncoding(mEncoding); if (mHttpLog.Length > 0) mRetsSession.SetHttpLogName(mHttpLog); mRetsSession.SetLogEverything(mLogEverything); mRetsSession.SetRetsVersion(mRetsVersion); mRetsSession.SetUserAgent(mUA); mRetsSession.SetUserAgentAuthType(mUAAuth); if (mUAPass.Length > 0) mRetsSession.SetUserAgentPassword(mUAPass); if (mEnableCacheing) flags |= RetsSession.MODE_CACHE; if (mNoSSLVerify) flags |= RetsSession.MODE_NO_SSL_VERIFY; if (mDisableStreaming) { /* * Caching is required in non-streaming mode. */ flags |= RetsSession.MODE_CACHE | RetsSession.MODE_NO_STREAM; } mRetsSession.SetModeFlags(flags); return mRetsSession; }