I been given a QAAWS and I need to pull out the data from it. For privacy issues I cannot give you the QAAWS but it is the same as this one.
I added the wsdl as a service reference, but I am not sure how to get the data since I have to enter the login and password. I can use SOAPUI and obtain an XML file that I can use but I want to make the process more automatic where I use the QAAWS with my website.
I haven't had any luck searching any good tutorials or guides. Has anyone dealt with these services before?
You can do the following:
In Visual Studio 10 create a new Console Application
Next add a web reference and use the web service WSDL URL given to you.
On the program.cs file write the following code (TestWeb here is the name of your Web Reference.):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using
ConsoleApplication1.TestWeb;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ConsoleApplication1.TestWeb.TestService test1 = new
ConsoleApplication1.TestWeb.TestService();
String message, creatorname, creationdateformatted, description, universe;
DateTime creationdate;
int queryruntime, fetchedrows;
ConsoleApplication1.TestWeb.Row[] row = test1.runQueryAsAService("<cms username>", "<password>", out message, out creatorname, out creationdate, out creationdateformatted, out description, out universe, out queryruntime , out fetchedrows);
int resultCount = row.Length;
Console.WriteLine("Message = " + message);
Console.WriteLine("Creator Name = " + creatorname);
Console.WriteLine("Creation Date = " + creationdate.ToString());
Console.WriteLine("Creation Date Formatted = " + creationdateformatted);
Console.WriteLine("Description = " + description);
Console.WriteLine("Universe = " + universe);
Console.WriteLine("Query Run Time = " + queryruntime);
Console.WriteLine("Fetched Rows = " + fetchedrows);
for (int i = 0; i < resultCount; i++)
{
Console.WriteLine(row[i].ShipperID + " " + row[i].CompanyName + " " + row[i].Phone);
}
Console.Read();
}
}
}
The username and the password can be written into the code if you want. This is originally from this page. I tested it against my own Web Service and it worked.
Related
I was using Extent Reports V3 with selenium / C# and I just upgraded to V4. Previously each run would give me a unique report based on the Date stamp / Class Name / Time stamp. However, after moving to V4, it always puts everything under the same file named "index" and a separate file named "dashboard" which is a file to sit above the other for navigation purposes.
Here is my code for starting the report:
htmlReporter = new ExtentHtmlReporter($"C:\\Test-Results\\" + dateStamp + "\\" + TestClassName + " " + timeStamp + ".html");
extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
extent.AddSystemInfo("Host Name", "Extent Framework");
extent.AddSystemInfo("Environment", "Local Machine");
extent.AddSystemInfo("User Name", "MyName");
htmlReporter.LoadConfig(CurrentDirectory + "\\extent-config.xml");
Now, each time I run a test, it overwrites the existing Index file with the new test results rather than appending my current results OR giving me a unique index file. I can provide any additional information needed about how i'm starting the reports / creating the tests if needed but for now here is what lives in my test file:
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
report.startReport("Report Name");
}
[ClassCleanup()]
public static void MyClassCleanup()
{
report.Flush();
}
[TestInitialize()]
public void MyTestInitialize()
{
string name = TestContext.TestName;
report.CreateTest(name);
}
It is enhanced feature of v4. To overcome it, We have to use ExtentV3HtmlReporter class in version 4. By using this class, We will be have Reports as we had. It will not override with index file. Also, There are many bugs get solved in V4. So things used same as version 4 report. You can compare both reports and you will be have your solution.
I started working on Extent Reports v4 recently and to solve files getting replaced issue you have to use v4 with v3 format as per #Ishita Shah answer, please see this Extent Reports generating two HTML Reports
Also, I have done a little tweak to generate new html files for every run without replacing the already generated files.
string fileName = "ExtentReport_" + DateTime.Now.ToString("MMM-dd-yyyy hh-mm-ss");
//Rename index.html with a new file name
renameFile("C:\\Reports\\index.html", fileName + "_Index.html");
//Replace "index.html" string inside the "index.html" file with the new filename
replaceTextHTMLFile("C:\\Reports\\" + fileName + "_Index.html", "index.html", fileName + "_Index.html");
same logic can be used for Dashboard.html and tags.html
renameFile:
public static void renameFile(string filePath, string oldFileName, string newFileName)
{
System.IO.File.Move(filePath + oldFileName, filePath + newFileName);
}
replaceTextHTMLFile:
public static void replaceTextHTMLFile(string filePath, string findText, string replaceText)
{
try
{
StreamReader objReader = new StreamReader(filePath);
string content = objReader.ReadToEnd();
objReader.Close();
content = Regex.Replace(content, findText, replaceText);
StreamWriter writerObj = new StreamWriter(filePath);
writerObj.Write(content);
writerObj.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception occurred. Messgae: " + e.Message);
}
}
I'm migrating to JUnit5 and I'd like to know if there is an easy way in JUnit5 to know when a test failed or not, just like we had in JUnit4 with TestWatcher.
I did some research and found similar, but open questions, like this one:
https://github.com/junit-team/junit5/issues/542
Since most of them are quite old, I'm asking just in case there is a recent solution.
The idea is to be able to do a screenshot or add some message into my log. So, is there a listener or extension or something that quickly allows me to manage the webdriver test's failure/pass/skip?
Thanks in advance!
OK, thanks glytching.
It was harder than I expected, but finally made it. As you pointed me, we need to create an external class (e.g. WatcherExtension) implementing BeforeTestExecutionCallback and AfterTestExecutionCallback and then evaluate the exceptions using the context given by the extension.
In this class we can add something like this:
#Override
public void afterTestExecution(ExtensionContext extensionContext) throws Exception {
Method testMethod = extensionContext.getRequiredTestMethod();
Boolean testFailed = extensionContext.getExecutionException().isPresent();
if (testFailed) {
if (!TESTDATA.excluded.contains(testMethod.getName())) {
takeScreenshot(testMethod);
logErrorMessage("Test " + testMethod.getName() + " failed on " + getAppVersion() + " using " + TESTDATA.browser);
} else {
logInfoMessage("Test " + testMethod.getName() + " was skipped on " + getAppVersion() + " using " + TESTDATA.browser);
}
} else {
logInfoMessage(testMethod.getName() + " was successfully executed on " + getAppVersion() + " using " + TESTDATA.browser);
}
Finally, you need to add this annotation to your test classes:
#ExtendWith(WatcherExtension.class)
public class MyTest extends TestFactory {
#Test
public void testMyTest() { //whatever }
}
Personally, I think this is something really basic and should be directly implemented by JUnit5 in future versions.
Thanks!
A client is trying to integrate some Broker Query code in to an existing web application. They have the following code:
public String doItNow(int keyA,
String schemaA,
String templateIdA) throws Exception {
loggerInfo("doItNow.start" +
", key:" + keyA +
", schema:" + schemaA +
", templateId:" + templateIdA);
StringBuffer sb = new StringBuffer();
PublicationCriteria pubCriteria = new PublicationCriteria(keyA);
loggerInfo("doItNow.PC:" + pubCriteria);
SchemaTitleCriteria schemaTitleCriteria = new SchemaTitleCriteria(schemaA);
loggerInfo("doItNow.STC:" + schemaTitleCriteria);
AndCriteria andCriteria = new AndCriteria(pubCriteria, schemaTitleCriteria);
loggerInfo("doItNow.AC:" + andCriteria);
Query query = new Query();
loggerInfo("doItNow.Query.0:" + query);
query.setCriteria(andCriteria);
loggerInfo("doItNow.Query.1:" + query);
String[] results = query.executeQuery();
for (String r : results) {
loggerInfo("doItNow.\tres:" + r);
}
ComponentPresentationAssembler cpa = new ComponentPresentationAssembler(keyA);
loggerInfo("doItNow.CPA:" + cpa);
for (String item : results) {
loggerInfo(":>" + item);
sb.append(cpa.getContent(item, templateIdA));
}
return sb.toString();
}
The code exectues as far as creating the Query object:
Query query = new Query();
At this point it hangs. No errors appear in the cd_core log file to suggest a reason for this. Can anyone suggest areas where can investigate to debug this further, or suggest a solution?
There was known issue with JRE version 1.6.0.29 and MSSQL jdbc driver. You need to either downgrade or upgrade to a different JRE version.
https://forums.oracle.com/forums/thread.jspa?threadID=2301826
The issue seems very similar to the issue reported with the driver and you do not see any error messages either.
Try changing the following line:
query.setCriteria(andCriteria);
to:
query.Criteria = andCriteria;
The SDL LiveContent example has a comment suggesting this change.
http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/concept_0AB6D192D7AB4EC18892631F519EF1DD
Have you added the correct includes? (Tridion.ContentDelivery.DynamicContent.Query Namespace)
Also as suggested by Chris, query in tridion 2011 does not have a property as setCriteria.
Use query.Criteria instead.
Also have you implemented the necessary changed in cd_storage_conf.xml?
I am using microsoft ajax minifier and I am using below piece of code to minify CSS and JS files, I wish to remove only comments and white space. I do not wish to rename or change the variable name or function name.
how can I use the options for default minification which will remove only Space and comments from my css and JS files. My code for .net utility looks like below....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace CallAjaxMin
{
class CallAjaxMin
{
static void Main(string[] args)
{
try
{
string sWebsiteScriptsFolder = #"D:\NewMerchandising\Javascript";
string[] strFiles = Directory.GetFiles(sWebsiteScriptsFolder);
foreach (string file in strFiles)
{
string sSourceFileName = file;
if (!((sSourceFileName == sWebsiteScriptsFolder + "\\eluminate.js") | (sSourceFileName == sWebsiteScriptsFolder + "\\EventMediaPlayer.js")))
{
string sDestFile = file;
ProcessStartInfo processinfo = new ProcessStartInfo(#"C:\Program Files\Microsoft\Microsoft Ajax Minifier\AjaxMin.exe");
processinfo.Arguments = "\"" + sSourceFileName + "\" -o \"" + sDestFile + "\" -clobber";
Process.Start(processinfo);
}
}
}
catch (Exception ex)
{
System.Console.WriteLine(ex.ToString());
}
}
}
}
Any ideas on how to remove only comments and spaces from CSS and JS files both? Is there any specific parameters or something that I need to pass here?
If you don't want to rename any variables or functions, simply add the -rename:none command-line argument to the Arguments string you are building. Check the documentation at http://ajaxmin.codeplex.com/wikipage?title=Command-Line%20Switches for a complete list of available switches.
I'm working on a web site (not a web application) in VS 2008 .Net 3.5 and it uses the single file .aspx model where the server code is included in the head portion of the html instead of using a .aspx.cs code behind page.
I'd like to quickly convert the files to use the code-behind model, but so far the only way I can do this is by removing the file, creating a new, code-behind aspx page of the same name, then manually copying in the aspx related code to the .aspx page and the server code to the .aspx.cs page.
Is there a faster way to do this?
I have seen two article that seem to answer this question, but unfortunately don't:
Working with Single-File Web Forms Pages in Visual Studio .NET and
How do you convert an aspx or master page file to page and code behind?
Both offer a simple solution whereby VS does the leg work, you just point it to a file and shoot. For whatever reason, they aren't working. The first article seems to refer to VS 2002 and the second seems to refer to a web application.
Is there any hope for a web site?
Also, maybe I'm seeing this the wrong way, is there an advantage to the single page model? I do plan on converting the whole web site to a web application soon, does the single page model work well in web applications?
If manual conversion is too time-intensive, and the automatic conversion isn't working, I think your only other option would be to build your own converter. You could write a simple console app which takes a directory path on the command line and processes every file in that directory. This isn't too hard - here, I'll get you started:
using System;
using System.IO;
class Program
{
const string ScriptStartTag = "<script language=\"CS\" runat=\"server\">";
const string ScriptEndTag = "</script>";
static void Main(string[] args)
{
DirectoryInfo inPath = new DirectoryInfo(args[0]);
DirectoryInfo outPath = new DirectoryInfo(args[0] + "\\codebehind");
if (!outPath.Exists) inPath.CreateSubdirectory("codebehind");
foreach (FileInfo f in inPath.GetFiles())
{
if (f.FullName.EndsWith(".aspx"))
{
// READ SOURCE FILE
string fileContents;
using (TextReader tr = new StreamReader(f.FullName))
{
fileContents = tr.ReadToEnd();
}
int scriptStart = fileContents.IndexOf(ScriptStartTag);
int scriptEnd = fileContents.IndexOf(ScriptEndTag, scriptStart);
string className = f.FullName.Remove(f.FullName.Length-5).Replace("\\", "_").Replace(":", "_");
// GENERATE NEW SCRIPT FILE
string scriptContents = fileContents.Substring(
scriptStart + ScriptStartTag.Length,
scriptEnd-(scriptStart + ScriptStartTag.Length)-1);
scriptContents =
"using System;\n\n" +
"public partial class " + className + " : System.Web.UI.Page\n" +
"{\n" +
" " + scriptContents.Trim() +
"\n}";
using (TextWriter tw = new StreamWriter(outPath.FullName + "\\" + f.Name + ".cs"))
{
tw.Write(scriptContents);
tw.Flush();
}
// GENERATE NEW MARKUP FILE
fileContents = fileContents.Remove(
scriptStart,
scriptEnd - scriptStart + ScriptEndTag.Length);
int pageTagEnd = fileContents.IndexOf("%>");
fileContents = fileContents.Insert(PageTagEnd,
"AutoEventWireup=\"true\" CodeBehind=\"" + f.Name + ".cs\" Inherits=\"" + className + "\" ");
using (TextWriter tw = new StreamWriter(outPath.FullName + "\\" + f.Name))
{
tw.Write(fileContents);
tw.Flush();
}
}
}
}
}
30 minutes coding, 30 minutes debugging. There are some obvious bugs - like, if your code contains a closing script tag anywhere inside, then it won't get exported correctly. The results won't be pretty, but this should take care of 90% of your code, and you should be able to clean up any problem results manually. There, does that help?
Basically you need to create a class file. Inherit the class from System.Web.UI.Page and then change the page directive of the page to point to the code behind.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>
Where Inherits is the name of your class file, and the CodeBehind is the code file you just created. You might need to reload the project to get the solution explorer to display the file nested, but even if you don't it should work.
You can also check out the accepted answer to for an alternative. How does IIS know if it's serving a Web Site or a Web Application project?
I don't know of a shortcut way to be honest.
Your probably best bet is to create a new page and copy paste across until everything works, then delete your source, rename your new file to the old name and rebuild.
Not ideal, but probably the quickest/cleanest/safest way to port over.
Thanks alot! Here is a slighlty modified version if your code is written i VB.Net. Just compile and run the converter in every folder that contains aspx sites.
using System.IO;
namespace Converter
{
class Program
{
const string ScriptStartTag = "<script runat=\"server\">";
const string ScriptEndTag = "</script>";
static void Main(string[] args)
{
string currentDirectory = System.Environment.CurrentDirectory;
var inPath = new DirectoryInfo(currentDirectory);
var outPath = new DirectoryInfo(currentDirectory);
if (!outPath.Exists) inPath.CreateSubdirectory("codebehind");
foreach (FileInfo f in inPath.GetFiles())
{
if (f.FullName.EndsWith(".aspx"))
{
// READ SOURCE FILE
string fileContents;
using (TextReader tr = new StreamReader(f.FullName))
{
fileContents = tr.ReadToEnd();
}
int scriptStart = fileContents.IndexOf(ScriptStartTag);
int scriptEnd = fileContents.IndexOf(ScriptEndTag, scriptStart);
string className = f.FullName.Remove(f.FullName.Length - 5).Replace("\\", "_").Replace(":", "_");
// GENERATE NEW SCRIPT FILE
string scriptContents = fileContents.Substring(
scriptStart + ScriptStartTag.Length,
scriptEnd - (scriptStart + ScriptStartTag.Length) - 1);
scriptContents =
"Imports System\n\n" +
"Partial Public Class " + className + " \n Inherits System.Web.UI.Page\n" +
"\n" +
" " + scriptContents.Trim() +
"\nEnd Class\n";
using (TextWriter tw = new StreamWriter(outPath.FullName + "\\" + f.Name + ".vb"))
{
tw.Write(scriptContents);
tw.Flush();
}
// GENERATE NEW MARKUP FILE
fileContents = fileContents.Remove(
scriptStart,
scriptEnd - scriptStart + ScriptEndTag.Length);
int pageTagEnd = fileContents.IndexOf("%>");
fileContents = fileContents.Insert(pageTagEnd,
"AutoEventWireup=\"false\" CodeBehind=\"" + f.Name + ".vb\" Inherits=\"" + className + "\" ");
using (TextWriter tw = new StreamWriter(outPath.FullName + "\\" + f.Name))
{
tw.Write(fileContents);
tw.Flush();
}
}
}
}
}
}
if your aspx file has 2 sections and your are able to split it in a mechanical way why you don't write just a small parser to automate the work? Shouldn't be hard, it's just plain text manipulation and a recursive file find.