I wish to know what is the correct approach to set the WebProxy to be used by HttpWebRequest.Proxy property.
Following are the options available:
Set the Proxy property to Null or Don’t set the property at all. This would use the IE’s default proxy configuration or default proxy in the web config.
Set the Proxy property to System.Net.GlobalProxySelection.GetEmptyWebProxy to bypass any proxy.
Set the Proxy property to WebRequest.GetSystemWebProxy. Set the proxy from IE proxy settings for the current user.
Between option 1 and 3 what is the correct approacy.
For best performance what should be the default Proxy. Should it be set to null or don't set any value at all or should it be GetSystemWebProxy.
I personally use option 1, if you do not set the value - the code will execute using the system settings. Setting a value of null is just useless code cluttering up your other code in my opinion. I don't know that there is a 'correct approach' - but if so I'd assume this to be it.
I use Proxy = Nothing as had other users experience issues in the past when they are using VPN / proxies in IE that require authentication & when IE is not open the program will not allow a connection. You could always give the user the option if you are distributing your software.
Related
Currently our tests have a specific hostname in the url (eg. http://foo.bar/whatever)
We want to resolve foo.bar to a different IP when running the tests.
Manually we would do this by changing the host file or using this piece of c# code:
var request = (HttpWebRequest)WebRequest.Create("http://ip-of-foobar/whatever");
request.Host = "foo.bar";
We need to have the correct hostname... maybe there is another way setting request headers in Selenium?
From my knowledge, there is NO API in selenium to set the IP of the server you want to open the browser. get() takes the URL which contains the domain name or IP address. you can not set the value as you set using C# libraries.
As you want to change the domain name to IP address, following are the two options available:
Keep the IP address in a file. Use the language libraries to read the value from the file and set it to a variable. Use that variable wherever you are referencing the URL. example: driver.get("http://"+variable+"/") to get the home page.
Use the test framework capabilities. parameterization (parameter in testng, example) or data references. This allows you to define the value outside the code and then refer the value using a variable name in the code. Same as the first option, but avoids File reading activity. During the run, change the value, so it will be reflected everywhere.
please let us know the language and framework you are using, so I can try to give the exact solution based on above options.
My client will access my company's site to retrieve data information, using a sub I am working on. This has to be done using a secured proxy, since his company blocks access to some sites. I can't test my sub on his computer and obviously he cannot send the proxy information (ie.:Username, passoword, ip, port...)
Sub login_sub()
url = "http://localhost/php004/loginExcelAddin.php?username=" + username + "&password=" + password
Dim httpObject As Object
Dim response As String
Set httpObject = CreateObject("WinHttp.WinHttpRequest.5.1")
httpObject.Open "GET", url, False
httpObject.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, proxyIP + ":" + proxyPortNumber
httpObject.send
response = httpObject.responseText
On Error GoTo errorHandler
If response = True Then
loggedIn = True
MsgBox "You are logged in"
End If
Application.Calculate
Exit Sub
errorHandler:
MsgBox "Login has failed"
End Sub
(Username, password, proxyPortNumber, proxyIP are public variables filled in a form)
I am struggled with this issue for a while. Anyone could tell me if I am going to the right direction, can I send this code for the client?
Thanks
Ah, I've been through this before many times in my career. From a test strategy perspective (rather than a review of your code above), there are several possible combinations of ways to test all this out:
The client's IT department should be able to provide you with specifications on how their proxy expects client identification information to be included in the outbound request. Some proxies may use alternative authentication information data in the request headers; you need to know exactly how the client's proxy requires the authentication data to be passed (this can get troublesome on Enterprise proxies that may use Active Directory/LDAP as intermediaries).
The ideal first stage of testing is to setup inside your own company a test authenticating proxy in as close as possible the same make, version, and configuration as the client's. Put your Excel code onto a laptop, and connect the laptop to the "outside" of this test proxy. This will allow you to test the code to work out bugs with accessing a similar proxy under your control.
Of course, its quite possible that the client's proxy may not behave quite like your test proxy, so even after doing step 2, there may still be problems once you give it to the client. If the client is allowed to use window sharing services like WebEx, you could then set up a WebEx session with the client, and have them share their screen with you while they are using your code for the first time. If it fails, you can talk them though a debugging session with Excel's debugger while you are watching the debugging results.
3a. If the client's IT Dept will allow a more comprehensive sharing tool that allows YOU to remotely control the client's desktop (while they are watching) that would even be more ideal. But if the client's IT Dept is already doing outbound proxying, they are likely too paranoid to allow this.
If a WebEx-like session is not allowed, then you could add diagnostic outputs into a log file which they could then send you, or verbally tell you in a telecon. This is not an optimal way to accomplish the debugging.
4a. Again if WebEx-like method is not allowed, but if the client has an Excel expert and an IT expert, you can get them to do the testing with you on a telecon. Again not optimal but is better than 3 because you are not talking with a clueless client.
Finally and worst-case, you may have to travel to the client's site to do final testing on their own computers (under of course the supervision of the client).
I have several modules(say Mod1) under my deployed application's(say App) manage modules and for the modules Mod1 I have to do these things:
Under General properties,
1. Check the box Override session management and click Apply.
2. Click the Enable cookies link under Session tracking mechanism.
3. Under General properties, uncheck the box Set session cookies to HTTP Only to help prevent cross-site scripting attacks and click Apply.
So far I could get myself to only check or uncheck the Override session management option under my application by first getting its id using the following code, but I am not able to figure out how to do the above 3 things for a module under my application.
appName = AdminConfig.getid('/Deployment:FileNetEngine/')
depObject = AdminConfig.showAttribute(appName, 'deployedObject')
sessionMgrAttrs = [['sessionManagement', [['enable', 'true']]]]
AdminConfig.create('ApplicationConfig', depObject, sessionMgrAttrs)
AdminConfig.save()
It would be great if I can get an answer to this in JACL, as I have all my scripts in jacl and I was trying with jython only for this piece.
Not sure if your problem is solved already.
I had the same problem, and I solved it with this post. Instead of "WebModuleConfig", I configure the "ApplicationConfig".
appName = AdminConfig.getid('/Deployment:testWebapp_war/')
depObject = AdminConfig.showAttribute(appName, 'deployedObject')
sessionMgrAttrs = [['sessionManagement', [['enable', 'true'], ['defaultCookieSettings', [['path','/xxx'], ['useContextRootAsPath', 'false'], ['name', 'JSESSIONID'], ['httpOnly', 'false']]]]]]
AdminConfig.create('ApplicationConfig', depObject, sessionMgrAttrs)
AdminConfig.save()
If you edit a service in Windows 7 and go to the Log On Tab, there is an option to "Allow service to interact with desktop". I'm trying to ensure that it is set for a certain service using VB.NET. Does anyone know of a way to do this?
Note: Doing this during the install of a program is not an option. It has to be done at run time.
Call ChangeServiceConfig with SERVICE_INTERACTIVE_PROCESS. The benefit of using Windows API is that it should takes care of the notification and consurrency part and invalidate the cache in other programs that uses service controller, and when something goes wrong, you get an error code back. Generally speaking you should not access the registry if you can use API to get/set a setting.
Service configuration is stored in the registry, under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\
With a key for each service.
It appears that the third to last flag within the Type value corresponds to the 'interact with desktop' value.
For example, a service set to NOT interact with the desktop has a value of:
Type REG_DWORD 0x0000010 (16)
whereas that same service, when set to be allowed to interact with the desktop has a value of:
Type REG_DWORD 0x0000110 (272)
I can't say that this is guaranteed as I've not done any testing, but it may be a good place to start. You'd need to restart the service before the changes to this value take effect.
I'm trying to send a message to the WCF-WSHttp adapter with a dynamic
send port from an orchestration, but BizTalk seems to always be
reverting back to the HTTP Adapter.
According to the docs that I've been able to find, I should just need
to set the transport type from my expression shape to get BizTalk to
use the WCF-WSHttp adapter, and I AM, but it still seems to be
reverting. Below is an example of my expression shape that's setting
the properties (as you can see, I've tried both
Microsoft.XLANGs.BaseTypes.TransportType and
BTS.OutboundTransportType):
Body(BTS.OutboundTransportType) = "WCF-WSHttp";
SendMessagePort(Microsoft.XLANGs.BaseTypes.Address) =
System.String.Format("{0}/Accept{1}", "http://myserver/myservice/
myservice.svc/Accept{0}", messageInfo.MessageType);
SendMessagePort(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-
WSHttp";
Probably are Craig :-)
When using a dynamic send port, BizTalk uses the "scheme" part of the url to decide which adapter to use.
When your url starts with "Http://" or "Https://" BizTalk would always use the HTTP adapter.
Similarly url's begining with ftp:// will use the FTP adapter.
Same works for custom adapaters as well - when you install the adapter's configuration you register the moniker to use; for example - the open source Scheduled Task adapter uses schedule:// (I believe).
Using dynamic send ports with WCF is slightly more involved than most other adapaters because of the various configuration that's required but you can find detailed explanation here, just scroll down to the "Dynamic Send Ports" section about half way down.
I ended up resolving my issue, but am still unsure of the reasoning for the behavior I saw.
The Expression shape mentioned in the question was located inside of an Atomic Scope. Once the Orchestration exited the scope containing the Expression shape, the Transport Type was reset back to its original value. Moving the Expression out of the atomic scope resolved the issue, in that the TransportType was set correctly.