Forum Discussion
Mark_Scattergoo
Feb 04, 2005Nimbostratus
Joe - thanks for the response. Turning off KeepAlives is not (to me) a really great solution for obvious performance reasons. Overiding the WebRequest object and manually setting the authentication header in each request works fine, and is probably a better work around. I hate to appear that I have been labouring the point, but I
wanted to be sure that F5 understood that there were three problems, which are:
1. get_virtual_address_list() is broken in 4.5.9 Build 2 (and possibly others).
Loc explained that this was a known interop issue with Microsoft's XML parser, and that a patch had been implemented in 4.6.2, so I have upgraded to 4.6.2.
2. The return type of get_virtual_address_list() had changed incorrectly from string[] to long[] in the WSDL in the 4.6.2 firmware.
I had already fixed that by modifying the proxy class to specify the correct return type (and pinning a reminder note on my forehead to not update the web reference...). Incidentally, the WSDL in 4.5.9 Build 2 is correct so I could also have imported it.
3. 4.6.2 introduces Apache changes which breaks Basic authentication with a Microsoft .Net web services client due to the web services client's incorrect handling of a 401 response. As you suggest, this could be fixed by disabling KeepAlives, or implementing the following code.
using System;
using System.Net;
using System.Web;
namespace BigIpPoC
{
public class F5VirtualServerWebRequest : F5VirtualServer.ITCMLocalLBVirtualServer
{
private string username = null;
private string password = null;
public F5VirtualServerWebRequest(
string Username,
string Password)
{
if (Username == null || Username.Length == 0)
throw(new Exception("Username parameter is null or empty"));
else if (Password == null || Password.Length == 0)
throw(new Exception("Password parameter is null or empty"));
else
{
username = Username;
password = Password;
}
}
protected override WebRequest GetWebRequest(
Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
string authInfo = username + ":" + password;
char[] authBuffer = authInfo.ToCharArray();
byte[] byteArray = new byte[authBuffer.Length];
for (int i = 0; i < authBuffer.Length; i ++)
{
byteArray[ i ]= Convert.ToByte(authBuffer[ i ]);
}
webRequest.Headers.Add("Authorization: BASIC " + Convert.ToBase64String(byteArray));
return webRequest;
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
F5VirtualServer.ITCMLocalLBVirtualServer bigIpVirtualServer = new F5VirtualServerWebRequest("", @"");
F5VirtualServer.ITCMLocalLBVirtualServer a = new F5VirtualServer.ITCMLocalLBVirtualServer();
bigIpVirtualServer.Url = "http://10.8.0.3/iControl/iControlPortal.cgi";
try
{
string[] bigIpVlanWildcardAdresses;
string[] virtualAddressList = bigIpVirtualServer.get_virtual_address_list(out bigIpVlanWildcardAdresses);
Console.WriteLine("Virtual address list contained " + virtualAddressList.GetLength(0) + " entries.");
}
catch (Exception e)
{
Console.Write(e.ToString());
}
}
}
}
It appears that everyone is on the same page now, so I'm happy and my application is working as expected.
Thanks to yourself and Loc for your input.
-Mark