Lotus Domino Designer: AJAX or some other way to open a URL to retrieve a data - ajax

Following Lotus Domino Designer: Add a button in the default calendar
The link is actually a SSO link (single sign-on) which is delivered by our API to connect the user to our application.
We must execute the url http://example.com/api.asp?cas=GETUSERTOKEN&rdn=9428521&login=mike&logincnx=adminAPIHays&pwdcnx=app
which returns the time-limited SSO link http://example.com/hays/array.asp?key=750EA68A476C9F8D26F9704B203205FDF64D2B849B688F169B398D217FFF570F54C1CB6B4635A494E504E624EDF3266D0D5C2A1210AA43EE3CD2098AE8B42DBF which connects the user.
By what means I can program this in Domino Designer?
If necessary we can put the button in a new something (not necessarily in the default calendar in fact).

Because you want to obtain another URL from an initial URL request, you will need to use a java agent to open a URL connection, and process the response to determine. The best approach is to use the J2SE URLConnection class. Once you're in a java agent, you can capture responses and store them in Documents.
If you need to do something in the UI after receiving the response, then you'll need to call the Java Agent from within a LotusScript function either from the view action or a form button. But if this is not required, you can also call the Java agent directly in view actions and form buttons. Java Agents have no UI output apart from the Java Debug Console. In Domino circles, Bob Balaban is a guru and has recently started to revise his Java in Domino writings. It provides a good insight into how it "hangs together" with the Domino API.
There are numerous examples scattered across the internet about using Java in Domino. IBM has published information on Java Agents in Domino. Some good examples can be found here, here, and here. The latest version of Domino Designer runs under Eclipse, so this may be of help to.

I did this in LotusScript:
Sub Click(Source As Button)
Dim objHttp As Variant
Dim url As String
Dim response As String
Set objHttp = CreateObject("Microsoft.XMLHTTP")
url = "http://foo.com/api.asp?cas=GETUSERTOKEN&rdn=9428521&login=mike&logincnx=adminAPIHays&pwdcnx=app"
objHttp.open "GET", url, False
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.send
newUrl = objHttp.responseText
Set w = New NotesUIWorkspace
w.UrlOpen newUrl
End Sub

Related

How to call an external API in truclient protocol of loadrunner

I am recording a script using truclient protocol.In my script ,i need to externally call an API which generates the Password. The password is fetched using the co-relation,which is used as an input for Login.
I am however unable to call the external API using the true client protocol.
Could anybody please suggest how to call an external API in true client protocol.
Have you tried the evaluate JavaScript step? You can post the message to the server and get the generated password during the runtime. XHR and fetch API should be supported in Chrome and Firefox, TCIE should support XHR.
Sure. Please check the detail steps:
Drag and drop an evaluate JS step from TruClient
Open the script editor
Add these code, make sure use the sync XHR to ensure the password is returned before the end step started:
var xhr = new XMLHttpRequest();
xhr.open("POST", '/server', false);
//Send the proper header information along with the request
xhr.setRequestHeader("xxx", "value");
xhr.send();
if (this.status === 200) {
// Request finished. Do processing here.
}
var password = xhr.response;
Change the login password step from plain text to JS and use
ArgsContext.password
to reference the previous received password.
If you have another questions please let me know. How to use the argument context you could reference this link.
BTW. the window and document object of the page can be referenced with AUT.window, AUT.document in TruClient.
Please check the help document from here.

How give trust to an external application accessing the Outlook Object Model (with all security options on)

I have a .NET application that interacts with Outlook like this:
Microsoft.Office.Interop.Outlook.Application app = new
Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem item = app.CreateItem((Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
item.PropertyAccessor.SetProperty(PsInternetHeaders + Foobar, 1031);
item.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
item.To = "a#test.com;b#test.com;c#test.com";
item.BCC = "cc#test.com";
item.Body = "Hello There!";
item.Display();
Be aware that I need to access the "PropertyAccessor" property.
In a normal environment this runs fine, but in a "secure" enviroment with this registry keys in place it just fails with Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)):
[HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\outlook\security]
"PromptOOMAddressBookAccess"=dword:00000000
"AdminSecurityMode"=dword:00000003
"PromptOOMAddressInformationAccess"=dword:00000000
Outlooks security model seems to have a "trustedaddins" list, but I'm not really sure if this applies to "external applications" as well and that exactly I need to register unter TrustedAddins (see here).
My main question would be: Can I just register and foobar.exe unter trustedaddins or is this not possible at all?
I know that I could lower or disable the security stuff, but this is not my choice ;)
Your only options are listed at How to avoid Outlook Security Alert when sending Outlook message from VBScript?
You also might want to set PsInternetHeaders properties to strings only, not ints.

How to test a Restful service which returns a JSON Response using UFT?

I have been using QTP 11 and we have had to migrate to UFT 12.02 now.
We have some REST services which have come for testing and problem is that it gives a JSON Response when done manually. I have not worked on C# before so is there any way I can configure this service using UFT API and validate the response using VB script which I am accustomed to.
I tried the following:
Dim lib, url, xmlHttp, json, JsonConvert, xmlDoc
lib = "C:\Bin\Net35\Newtonsoft.Json.dll"
url = "http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo"
Set xmlHttp = CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "POST", url, False
xmlHttp.send
json = "{ ""?xml"": { ""#version"": ""1.0"", ""#standalone"": ""no"" }, ""root"":" & xmlHttp.responseText & "}"
Set JsonConvert = DOTNetFactory.CreateInstance("Newtonsoft.Json.JsonConvert", lib)
Set xmlDoc = JsonConvert.DeserializeXmlNode(json)
MsgBox xmlDoc.InnerXml
But I do not have the dll available with me, I am unable to test the URL with this.
If this is the correct way then can anyone let me know how can I get this dll installed.
UFT internally uses Newtonsoft.Json framework (like many other HPE products), so it already includes such DLL.
You just need to update the path to point to UFT\bin directory, which by default is:
lib = "C:\Program Files (x86)\HP\Unified Functional Testing\bin\Newtonsoft.Json.dll"
Now, from API testing perspective, you can use checkpoints to validate the results. See Image

XMLHTTP-Request (AJAX) with VBSkript does not work with proxy connection

I'm using a XMLHTTP-Request to get data from a website to work with them in VBS. This works great with a default internet connection. But currently I've to deal with a customer, which uses a "proxy" connection.
Unfortunately I'm not very familiar to different proxy-solutions. The behavior is: I'm opening the browser and I'll get a authorisation dialog (username/password). After entering username/password it can be accessed to all websites. If I close the browser and start it again, the autorisation dialog appears again.
Here a little bit of code. I'm working with a "better notepad", so I can't see other object properties:
Set XMLHTTP = CreateObject("Microsoft.XMLHTTP")
XMLHTTP.Open "GET", "http://www.mywebsite.de/getData.php" ,0
XMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLHTTP.Send("content=1")
MsgBox(XMLHTTP.responseText)
If I execute this code on the machine with the forced proxy, I'll get a "access denied" error immediately.
How can I add proxy authorisation support here? If indeed such a thing is possible ...
Thank you!
I've found the solution: I have to change the class, because Microsoft.XMLHTTP does not support proxy configurations:
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.4.0")
xmlhttp.Open "POST","http://www.yourwebsite.com",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setProxy 2, "192.168.0.222:8080"
xmlhttp.setProxyCredentials "your_username" , "password_for_username"
xmlhttp.send
MsgBox(xmlhttp.responseText)
Notice some important details:
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.4.0")
setProxy and setProxyCredentials methods requires version number:
It's important to use a version number at the end of the parameter. If I don't use a version number, it will look for an old version of the class without the setProyx and setProxyCredentials methods. An error message appears ("object does not have the method ...").
Version number isn't trivial:
But the version number itself isn't trivial as well. In my local enviroment (W7x64) I'll have to take version number "4.0", but at my client's server it doesn't work ("could not create an object ..."). I'll have to take version number "6.0". If you're not sure, which version is installed, you can look it up in the registry, just search for "MSXML2.ServerXMLHTTP". In my case there are various keys with the right version number:

Getting a response uri

I'm new to Windows phone 7 application development. I'm currently developing an app in which I wish to do a HTML request and display the result obtained in Web browser. For example, Suppose I give the below URI
"http://m.imdb.com/find?q="+search_string (where search_string is a variable)
I want to take the result obtained from this and display it on the web browser. I've been searching regarding this for past 1 day... Didn't get any fruitful results. So please redirect me either to a suitable tutorial page or please give a sample code?
WebBrowserTask wbt = new WebBrowserTask();
wbt.URL = "http://m.imdb.com/find?q="+search_string
wbt.Show();
this will allow you to launch the url in the browser.
WebBrowserTask

Resources