How to validate third party server urls in hybris? - sap-commerce-cloud

Actually in my Hybris application I am using different third party servers ,So I want to validate the third party URLS that its responding or not.So how can I do that?

You can develop Cron Job for it.
In hac you can run script. Example groovy script below:
URL url = new URL("http://mkysoft.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int httpCode = connection.getResponseCode();
return "Http code: " + httpCode;

Related

Manually add cookies to request in C# Web test

Hi in one of my response i am getting this xml
<root><err>0</err><errDesc></errDesc><state>3</state><p1>{C4739B96-E12A-429B-9A03-0B5B5F814D3C}</p1><p2>{1C33A258-D50E-4D44-8309-83665FC6073E}</p2><p5>1</p5><p6>QdjXQJy0SVnamdLJqMMHz/Cxtu8Dbw21q5caSX9uwoBlZDvBfHJx1R7QfknQ+f564YfmnEyRnJ1TJ5DF+ZOK2g==</p6><p7></p7><p8>{00000000-0000-0000-0000-000000000000}</p8><p9>0</p9><returnmessage></returnmessage></root>
I need to extract id between p6 tags and pass it as a cookie in subsequent request as CPSession.
How to achieve this in C# Web Performance Testing.
Any help would be hugely appreciated.
I am trying to write a web test request plugin and in its prerequest method i am trying to write a method to achieve this with following code
CookieContainer gaCookies = new CookieContainer(); Uri target = new Uri("http://susday4446.corp.ncr.com:8091/core/ui/uiBrowser.aspx");
> gaCookies.Add(new Cookie("CPSession", "QdjXQJy0SVnamdLJqMMHz/Cxtu8Dbw21q5caSX9uwoBlZDvBfHJx1R7QfknQ+f564YfmnEyRnJ1TJ5DF+ZOK2g==");
> { Domain = target.Host }
But this is not able to add cookie in this request.
Right now all i am trying to do is passing CPSession as a cookie its value i have hardcoded.

Make multiple page Logins with WebDriver Selenium using Groovy and Spring Boot

i'm using Geb Selenium with Phantomjs Driver, realy using a RemoteWebDriver for interact with a web page using the phantomjs running over a console, i'm using also Spring boot so i call my Groovy Geb scripts from a REST method, what i want is to, for example, running scripts that login two different users asynchronously and make some work in their accounts, but when i run my code is like the first loged user is used over the second, i check in my code if the user is loged then go to his account, is like Selenium or Phantomjs uses an only one Browser for all my request so when i do a request for login and then make another one the first login is presents, is there a way for run my request in an isolated browser or driver in my case, or maybe is because some kind of cookies?
this is the code where i do my login using Groovy geb (called from a REST method in Spring):
public void test_make_login(String login, String password){
def String imgUrl = null
Browser.drive {
to MyPage
makeLogin(login,password){
println page
imgUrl = profileThumbnail.attr("src")
}{
imgUrl = "none"
}
println imgUrl
}
}
I'm using Angular $resource for make my REST requests, in my program i want to get the profile loged picture of each user but all users haves the first loged accound picture.

how to run agents in xpages from a web browser?

I got this problem and started googling about it, but no direct answer were pulled out. My query problem is, I'm doing an xpage project and I need to run an agent that uses lotusscript as a language. The agent is used to read a TSV text file and create notes document from each record there. Independently running the agent went very good, no problem. But when I tried to run it from xpage using this script :
var doc = database.createDocument();
var field = getComponent("filePath");
var agent:NotesAgent = database.getAgent("UploadTSV");
if (agent != null) {
agent.runWithDocumentContext(doc);
TSVDoc.setValue("filePath","Agent run");
}
else{
TSVDoc.setValue("filePath","Agent did not run");
}
it did not run. I'm just wondering what I did wrong. Thank you in advance.
My way to do this would be to trigger the agent (either it's based on a page load event or on a user click event) via client Javascript. The URL to run an agent is nothing more than
http://yourhost/yourapp.nsf/youagent?openagent
So I'd just make a AJAX call to that URL to run the agent. To get return values (errors of anything else) I'd add some code to the agent's print output. Print statements (in Lotusscript) in agents called from the browser produce a HTTP response. Similar for agents written in Java but there you have to do more than simple sysouts.

.Net Client Object Model in Sharepoint returns 500 internal server error while executeQuery

I am trying to see all the lists in my Site using sharepoint Client Object model , following is my code
using (ClientOM.ClientContext ctx =
new ClientOM.ClientContext(UrlTextBox.Text))
{
//Get the site
ClientOM.Web site = ctx.Web;
ctx.Load(site);
//Get Lists
ctx.Load(site.Lists);
//Query
ctx.ExecuteQuery();
}
The above code throws following Error
"The remote server returned an error: (500) Internal Server Error" Tried passing in the credentials too, but didn't work, tried passing DefaultNetworkCredentials too. No luck..
Please advice.
Check everything below and make sure nothing has stopped running.
1. Check all of your app pools.
2. Check these SharePoint Services.
3. Check the IIS Admin Service.
You need a credential before every executeQuery() :
ctx.Credentials = new NetworkCredential("LoginID", "LoginPW","LoginDomain");

Programmatically connect to ASP.NET WebAPI sitting behind ForeFront UAG

I have a WebAPI built using ASP.NET MVC4. It is a simple API for getting data (simple HTTP GET requests). The API is stable and has been working with our mobile (MonoTouch) app for quite some time. Now we're putting ForeFront UAG in front of the API (simply changed web.config to use windows auth. Testing the security and API through a browser e.g. Chrome, and the UAG login is presented (when hitting API first time). Enter your credentials and then you get the data back for the API GET request. All what you'd expect. Now, from .NET code (no browser) I want to do the same thing. I've seen examples accessing SharePoint programmatically and some windows phone stuff, but none of them seem to work for ASP.NET MVC4 WebApi calls from just regular old .NET code (which I'll eventually use in MonoTouch).
Anyone have an example of how to Authenticate and then make HTTP GET request successfully through UAG to an ASP.NET MVC4 WebApi?
I don't have the disposal over a ForeFront UAG so I can't test this. But in general you have a few options. The samples are snippets and some code is left out for readability.
WebClient / HttpWebRquest
CredentialCache credentials = new CredentialCache();
credentials.Add(new Uri(url), "NTLM", new NetworkCredential(userName, password, domain));
//WebClient
var webClient = new WebClient();
webClient.Credentials = credentials;
//HttpWebRequest
var request = HttpWebRequest.Create(url);
request.Credentials = credentials
HttpClient
WebRequestHandler clientHandler = new WebRequestHandler();
clientHandler.UseDefaultCredentials = true;
clientHandler.AllowPipelining = true;
clientHandler.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
ProgressMessageHandler progress = new ProgressMessageHandler();
httpClient = HttpClientFactory.Create(clientHandler, progress);
You have also the options of using third party libraries to get this job done, like RestSharp or Service Stack.
Personally I make use of RestSharp because of the ease of use and serializing/deserializing capabilities.

Resources