I'm having some difficulties to consume a Web Service in VBScript. Everytime I try to run it presents some error (Missing parameters / Internal server error / Status 500). I don't know what can be wrong. can you give me some help?
Here's my VBScript code:
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.open "POST","http://192.168.0.32:9090/webservice1.asmx/Conecta?
sID=1",False
oXMLHTTP.setRequestHeader"Content-Type","application/x-www-form-urlencoded"
oXMLHTTP.send()
msgBox oXMLHTTP.Status
msgbox oXMLHTTP.StatusText
msgbox oXMLHTTP.responseText
And here is my Web Service. Very simple:
namespace WebApplication1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http:// tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string Conecta(string sID)
{
if (sID == "1")
{
return "ok";
}
return "Not ok";
}
}
}
Sorry. I'm noob at this. Any help is very appreciated.
Thank you!!!
Please, see this reference
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.open "POST","http://192.168.0.32:9090/webservice1.asmx/Conecta",False
oXMLHTTP.setRequestHeader"Content-Type","application/x-www-form-urlencoded"
oXMLHTTP.send "sID=1"
msgBox oXMLHTTP.Status
msgbox oXMLHTTP.StatusText
msgbox oXMLHTTP.responseText
Related
Trying to run selenium tests in AWS Lambda. Read below links and felt confident to implement similar tests with NET Core 2.1.
https://blackboard.github.io/lambda-selenium/
https://medium.com/clog/running-selenium-and-headless-chrome-on-aws-lambda-fb350458e4df
https://aws.amazon.com/blogs/devops/ui-testing-at-scale-with-aws-lambda/
Here is my complete lambda function code.
using System;
using System.Collections.Generic;
using System.IO;
using Amazon.Lambda.Core;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace selenium_lambda_poc1
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public void FunctionHandler(string input, ILambdaContext context)
{
context.Logger.LogLine("Starting...");
var driver = GetDriver(context);
driver.Navigate().GoToUrl(input);
var title = driver.Title;
LambdaLogger.Log("Window Title: " + title);
driver.Quit();
context.Logger.LogLine("Ending...");
}
public IWebDriver GetDriver(ILambdaContext context)
{
var lambdaTaskRootPath = Environment.GetEnvironmentVariable("LAMBDA_TASK_ROOT");
context.Logger.LogLine(lambdaTaskRootPath);
Environment.SetEnvironmentVariable("webdriver.chrome.driver", lambdaTaskRootPath + #"/Lib/chromedriver");
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = lambdaTaskRootPath + "/Lib/chrome";
var chromeBinaryPath = options.BinaryLocation;
var chromeDriverPath = lambdaTaskRootPath + #"/Lib/chromedriver";
context.Logger.LogLine("Chrome Path? " + chromeBinaryPath);
context.Logger.LogLine("ChromeDriver Path? " + chromeDriverPath);
context.Logger.LogLine("Chrome - Available? " + File.Exists(chromeBinaryPath).ToString());
context.Logger.LogLine("ChromeDriver - Available? " + File.Exists(chromeDriverPath).ToString());
options.AddArguments(new List<string>() {
"--headless",
"--disable-gpu",
"--single-process",
"--no-sandbox",
"--data-path=/tmp/data-path",
"--homedir=/tmp/homedir",
"--disk-cache-dir=/tmp/cache-dir",
"--allow-file-access-from-files",
"--disable-web-security",
"--disable-extensions",
"--ignore-certificate-errors",
"--disable-ntp-most-likely-favicons-from-server",
"--disable-ntp-popular-sites",
"--disable-infobars",
"--disable-dev-shm-usage",
"--window-size=1366,1024",
"--enable-logging"
});
var driver = new ChromeDriver(lambdaTaskRootPath + "/Lib/", options, TimeSpan.FromMinutes(1));
return driver;
}
}
}
When I test my lambda function, getting the below and I've been struggling with same issue for the last 3 days. Would be grateful if someone can help me out here
Starting ChromeDriver 2.39.562737 (dba483cee6a5f15e2e2d73df16968ab10b38a2bf) on port 38471
Only local connections are allowed.
The HTTP request to the remote WebDriver server for URL http://127.0.0.1:38471/session timed out after 60 seconds.: WebDriverException
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at selenium_lambda_poc.Function.GetDriver(ILambdaContext context) in C:\Users\sureshraja.s\source\repos\selenium-lambda-poc\selenium-lambda-poc\Function.cs:line 97
at selenium_lambda_poc.Function.FunctionHandler(String input, ILambdaContext context) in C:\Users\sureshraja.s\source\repos\selenium-lambda-poc\selenium-lambda-poc\Function.cs:line 34
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
Firstly I had a problem with the antiJARLocking attribute that was showing an error in the console:
WARNING [http-nio-8084-exec-69] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule] {Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
But I commented this part and it does not appear anymore.
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/DivulgueAqui"/>
<!-- antiJARLocking="true" -->
Then got a bug with the netbeans monitor
Showing this error:
The request can not be recorded most likely because the NetBeans HTTP Monitor module is disabled.
But in my last tests to get this error and put here for you this did not happen!
When I'm trying to run the web service it returns me code 500.
The information is arriving in the method and insert but when it arrives in the dao.insert (u);
The service stops working
#POST
#Consumes(MediaType.APPLICATION_JSON)
#Path("usuario/inserir")
public String insertUsuario(String json){
UsuarioDao dao = new UsuarioDao();
Usuario u = new Usuario();
JSONObject jsonObject = null;
JSONParser parser = new JSONParser();
String nome;
String email;
String senha;
try {
jsonObject = (JSONObject) parser.parse(json);
nome = (String) jsonObject.get("nome");
email = (String)jsonObject.get("email");
senha = (String) jsonObject.get("senha");
u.setNome(nome);
u.setEmail(email);
u.setSenha(senha);
dao.inserir(u);
} catch (ParseException ex) {
System.out.println("WS.webService.insertUsuario()" + ex);
Logger.getLogger(webService.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
My question is. How do I solve this problem?
In the step by step guide at:
https://github.com/smsohan/MvcMailer/wiki/MvcMailer-Step-by-Step-Guide
It is stated that the .net mail lib is used (System.Net.Mail).
In medical transactions, there is a need to change servers based on country region and record if the mail message was sent with status.
.net mail lib will do this but I have trouble understanding where to put the following code pieces when Using MVC Mailer:
.net Mail Lib-->
SmtpClient client = new SmtpClient(server, port);
client.credentials = CredentialCache.DefaultNetworkCredentials;
MVC Mailer-->
public ActionResult SendWelcomeMessage()
{
UserMailer.SmtpClient(server, port);
UserMailer.credentials = CredentialCache.DefaultNetworkCredentials;
UserMailer.Welcome().SendAsync();
return RedirectToAction("Index");
}
static bool mailSent = false;
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
// Get the unique identifier for this asynchronous operation.
String token = (string) e.UserState;
if (e.Cancelled)
{
Console.WriteLine("[{0}] Send canceled.", token);
}
if (e.Error != null)
{
Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
} else
{
Console.WriteLine("Message sent.");
}
mailSent = true;
}
if MailSent is false, then write to Critical Log Error.
I am not sure where the client setting for .net setting should go.
Should they go in the controller as I have done above or in the Mailer method.
Thanks for any advice.
Regards,
Vic
I had the same need.
To do so, i have created a custom mail sender class :
Public Class CustomMailSender
Inherits System.Net.Mail.SmtpClient
Implements ISmtpClient
Public Sub Init(senderEmail As String, password As String)
Me.Credentials = New System.Net.NetworkCredential(senderEmail, password)
End Sub
Public Overloads Sub SendAsync(mail As MailMessage) Implements ISmtpClient.SendAsync
MyBase.SendAsync(mail, Nothing)
End Sub
Public Overloads Sub SendAsync(mail As MailMessage, userToken As Object) Implements ISmtpClient.SendAsync
MyBase.SendAsync(mail, userToken)
End Sub
Public Overloads Sub Send(mail As MailMessage) Implements ISmtpClient.Send
MyBase.Send(mail)
End Sub
Public Shadows Event SendCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Implements ISmtpClient.SendCompleted
End Class
Then inside your email controller, you use it like that
Public Class EmailController
Inherits MailerBase
Public Sub New()
MyBase.New()
Me.CustomMailSender = New CustomMailSender
End Sub
Public Property CustomMailSender As CustomMailSender
Public Sub Sample()
Dim mvcMailMessage As MvcMailMessage = Populate(Sub(i)
i.ViewName = "Sample"
i.To.Add("some1#somewhere.org")
i.Subject = "Boo!"
End Sub)
mvcMailMessage.Send(Me.CustomMailSender)
End Sub
End Class
Yeah, i know that's VB, but i'm a VB guy ! :>
Hope this helps :)
I have a clearQuest Web (running on Linux) and wants to create a sharepoint site when a new record is created (using a perl script).
How can I do it - is there any sharepoint web service that I can use to create a site.
I beleive that I need a perl module for web services, how do I add it to the perl installation of the clearQuest web server ?
Does any one has expirienc with this ?
I have not worked with perl script. But check out http://sharepoint site/_vti_bin/sites.asmx webservice. This webservice can be used manage sites.
I created a custom web service for creating sites in SharePoint (WSS 3), as I couldn't find a way to do it using the existing web services.
The code looks something like this:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class CreateSiteWebService : System.Web.Services.WebService
{
[WebMethod]
public string CreateSite(
string strWebUrl,
string strTitle,
string strDescription,
uint nLCID,
string strWebTemplate,
bool useUniquePermissions,
bool bConvertIfThere
)
{
SPWeb newWeb = null;
SPSite site = SPContext.Current.Site;
newWeb = site.RootWeb.Webs.Add(strWebUrl, strTitle, strDescription, nLCID, strWebTemplate, useUniquePermissions, bConvertIfThere);
newWeb.Navigation.UseShared = true;
newWeb.Update();
//try to get it to appear in quick launch:
SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
SPNavigationNode menuNode = null;
foreach(SPNavigationNode n in nodes)
{
if (n.Title == "Sites")
{
menuNode = n;
break;
}
}
if (menuNode == null)
{
menuNode = new SPNavigationNode("Sites", site.Url + "/_layouts/viewlsts.aspx?ShowSites=1", false);
nodes.AddAsFirst(menuNode);
}
SPNavigationNode navNode = new SPNavigationNode(strTitle, strWebUrl, false);
menuNode.Children.AddAsLast(navNode);
parent.Update();
parent.Dispose();
site.Dispose();
string url = newWeb.Url;
newWeb.Dispose();
return url;
}
}
Hope that helps.
Im trying to develop an server /client application. The server will be a bunch of webservices, the idea was to expose methods like:
Company GetNewCompany(); //Creates an new Company Object
Save(Company C);
CompanyCollection GetCompany(Query q);
Where Query object is part of Subsonic 2.1. But the problem is that SubSonic is not built for this, Have I missed something here? or is it just impossible to to use subsonic query language over SOAP?
This would have been great feature, becuase then it is really easy to make an application server using subsonic.
Br
Soren.
If you want to use subsonic v3 you can look at this issue that talks about IUpdatable:
http://code.google.com/p/subsonicthree/issues/detail?id=30
This will let you use ado data services somewhat painlessly. You use a DB constructor that take a URI argument. This probably won't be a part of v3 but you could make changes like this yourself.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WcfClientTest.NorthwindService;
namespace WcfClientTest
{
/// <summary>
/// Summary description for WcfTest
/// To run these tests, load this project, and somehow get a server running at the URI.
/// This can be done by updating the service reference to start the development server.
/// </summary>
[TestClass]
public class WcfTest
{
private string baseURI = "http://127.0.0.1:49649/Northwind.svc";
private DB ctx;
/// <summary>
/// Sets up test.
/// </summary>
[TestInitialize]
public void SetUp()
{
ctx = new DB(new Uri(baseURI));
}
[TestCleanup]
public void Cleanup()
{
}
[TestMethod]
public void Select_Simple_With_Variable()
{
int categoryID = 5;
IQueryable<Product> result = from p in ctx.Products
where p.CategoryID == categoryID
select p;
List<Product> products = result.ToList();
Assert.AreEqual(7, products.Count());
}
[TestMethod]
public void TestAddNew()
{
// add customer
var c = new Customer
{
CustomerID = "XXXXX",
ContactTitle = "Prez",
Country = "USA",
ContactName = "Big Guy",
CompanyName = "Big Guy Company"
};
ctx.AddToCustomers(c);
ctx.SaveChanges();
IQueryable<Customer> qCustomer = from cust in ctx.Customers
where cust.CustomerID == "XXXXX"
select cust;
Customer c2 = qCustomer.FirstOrDefault();
Assert.AreEqual("XXXXX", c2.CustomerID);
if (c2 != null)
{
ctx.DeleteObject(c2);
}
ctx.SaveChanges();
IQueryable<Customer> qCustomer2 = from cust in ctx.Customers
where cust.ContactName == "Big Guy"
select cust;
// Returns null if the row isn't found.
Customer c3 = qCustomer2.SingleOrDefault();
Assert.AreEqual(null, c3);
}
}
}
And this is all there is to the service:
using System.Data.Services;
using Northwind;
namespace NorthwindService
{
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults=false)]
public class Northwind: DataService<DB>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.UseVerboseErrors = true;
}
}
}
And for web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>