How to avoid Agile Web Project Pitfalls
Posted in Labels: agile, SCRUM, Web Project Pitfalls |
Posted in Labels: .NET, Remove WS-Security, WCF, Web services |
While invoking web service request using WSE 3.0 client, I was getting null reference exception errors. On investigating code I found bunch of WS-Addressing and WS-Security headers added to my request. The .NET WSE 3.0 package seems to be adding them by default. Is there any way to get rid of these?
The solution I found takes 3 steps:
1.) Create custom ClientOutputFilter
2.) Create a custom Assertion that uses filter from step 1
3.) Bind service to custom Assertion
Step 1: Custom Filter(Called by Custom Assertion)
Class ClientOutputFilter
Inherits SendSecurityFilter
Private parentAssertion As UsernameClientAssertion
Private filterContext As FilterCreationContext
Public Sub New(ByVal parentAssertion As UsernameClientAssertion, ByVal
filterContext As FilterCreationContext)
MyBase.New(parentAssertion.ServiceActor, False,
parentAssertion.ClientActor)
Me.parentAssertion = parentAssertion
Me.filterContext = filterContext
End Sub
Public Overrides Function ProcessMessage(ByVal envelope As
Microsoft.Web.Services3.SoapEnvelope) As
Microsoft.Web.Services3.SoapFilterResult
Dim securityElement As XmlElement = envelope.CreateElement("wsse",
"Security", "http://schemas.xmlsoap.org/ws/2002/07/secext")
Dim mustUnderstandAttribute As XmlAttribute =
envelope.CreateAttribute(envelope.DocumentElement. Prefix, "mustUnderstand",
envelope.DocumentElement.NamespaceURI)
Dim userToken As New UsernameToken(parentAssertion.username,
parentAssertion.password, PasswordOption.SendPlainText)
mustUnderstandAttribute.Value = "true"
securityElement.AppendChild(userToken.GetXml(envel ope))
envelope.CreateHeader.AppendChild(securityElement)
Return SoapFilterResult.Continue
End Function
End Class
Step 2: Custom Assertion
Public Class UsernameClientAssertion
Inherits SecurityPolicyAssertion
Public username As String
Public password As String
Public Sub New(ByVal username As String, ByVal password As String)
Me.username = username
Me.password = password
End Sub
Public Overloads Overrides Function CreateClientOutputFilter(ByVal context
As FilterCreationContext) As SoapFilter
Return New ClientOutputFilter(Me, context)
End Function
Public Overrides Function CreateClientInputFilter(ByVal context As
FilterCreationContext) As SoapFilter
' we don't provide ClientInputFilter
Return Nothing
End Function
Public Overrides Function CreateServiceInputFilter(ByVal context As
FilterCreationContext) As SoapFilter
' we don't provide any processing for web service side
Return Nothing
End Function
Public Overrides Function CreateServiceOutputFilter(ByVal context As
FilterCreationContext) As SoapFilter
' we don't provide any processing for web service side
Return Nothing
End Function
End Class
Step 3: Bind proxy to custom assertion
Private WS As New Service.ServicenameWSE
Private token As UsernameToken = New UsernameToken(USERNAME, PASSWORD,
PasswordOption.SendPlainText)
ProvideUsernameToken.Assertions.Add(New UsernameClientAssertion(USERNAME,
PASSWORD))
WS.SetClientCredential(token)
WS.SetPolicy(ProvideUsernameToken)
Good luck, if anyone has a better way to do this I'm all ears.
Posted in Labels: facebook, google, search, Social Media, twitter, websites |
The name alone instantly polarises reactions, but Twitter looks set to have a far greater impact on our lives than anyone could have imagined.
If you haven't heard the phrase already, Real Time Search is likely to become one of the buzz words of 2010. What it refers to is the ability to search for information published on the Internet as it happens and it is something Twitter has perfected as it sought to organise the tens of millions of tweets sent through the service every day. Consequently Twitter users can immediately see what the trending topics (read: hot topics) of the minute/hour/day/week are, read about developments and get involved.
High profile examples of this during 2009 include the breaking news of Michael Jackson's death, the Hudson river plane crash and the Trafigura waste dumping scandal. In fact multiple heavyweight news organisations now scan Twitter on a daily basis for breaking news and trends in public opinion - all of which is pulling traffic away from traditional search engines. After all, why use Google to find what the weather is like in Madrid when a Twitter search can pinpoint a local who made comment on it in the last five minutes and posted a picture?
The keyword in all this is relevancy. The battle for web supremacy lies in the service which can provide the most relevant information to the user and a key aspect of this is speed. So while traditional search engines work by web search crawls which index them into a logical order, the delay can take hours when the goal is seconds. Consequently the Twitter licensing deal will initially see users Tweets integrated into Google and Bing search results (Twitter users have the right to opt out) and the impact of this is profound.
While what Ashton Kutcher or Stephen Fry had for breakfast is unlikely to trouble CNN, it means the on-location reports from (for example) the Hudson River crash would now break through search engines not the BBC or Reuters. Never before has such people power been harnessed. Of course such a system is also open to great abuse, the recent tasteless fad for spreading fake celebrity deaths on Twitter is a prime example, but with this door now open it is extremely unlikely to ever be closed.
Still not convinced? YouTube and Facebook have recently both announced plans to integrate this technology into their respective sites. So that's Microsoft, Google, Facebook, YouTube (Google by proxy) and Twitter all focused on real time search. Resistance is understandable, but in the long run it's futile.
Follow me on www.twitter.com/mujeebhassan
Posted in Labels: .NET, underlying connection, visual studio 2005, WCF |
Recently i encountered some errors with web services regarding webService response.
The full Exception that was thown was :
"Server was unable to process request. -> the underlying connection was closed: A connection that was expected to be kept alive was closed by the server"
Digging a little in , i found few reasons that may cause that error.
idle time on the client side is greater than on the server side.
network issues that prevent the Keep-Alive feature from being committed. (firewalls, proxies and so...).
what is this KeepAlive feature : this "great" feature actually keeps the connection between the WebService client and server open for a defined amount of time,thus enhancing WebService interaction performance by eliminating the need to open a new connection each time.
unfortunately, the time for that window is not synchronized between the client and the server. this situation creates a problem, on which the client may think that the connection is still open, but the server closed it.
so, what can be done so solve that matter ?
ensure the reasons above would not happen disable the KeepAlive feature.
since, ensuring that our time is not greater than the one on the server side is impossible when dealing with 3rd party services, not even mentioning the 3rd party network configuration, the optimal solution for this issue will be disabling the Keep-Alive feature.
how can we do that ?
when adding a web reference with visual studio 2005, it automatically generates a file called reference.cs which is used as a proxy to the web service on the server.
this is the place which we should do the "fix".
there are 2 ways to prevent this certain problem from happening :
set the KeepAlive property to false
use the HTTP protocol version 1.0 (difference between http 1.0 and 1.1)
since our "proxy" is being generated each time we update our web reference, we would not want the change to be made in the reference.cs file, since it can be overridden the next time we will do "update web reference"
what we can do, is use the "partial class" feature that presented in .Net 2.0 framework to solve this issue.
namespace theNamespaceOfYourServiceAsStatedInTheReferenceFile
{
public partial class MyService
{
///
/// this method overides the base getWebRequest,
/// thus preventing the KeepAlive feature
///
/// the given uri
///
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
// Do the base class operation and obtain the specific web request
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri);
// do the keep alive handling
return Utils.DisableKeepAlive(webRequest);
}
}
now we need to decide how we are going the disable it(write the DisableKeepAlive in our utils)
///
/// This method should disable the keep alive feature
///
/// the needed HttpWebRequest
///
public static HttpWebRequest DisableKeepAlive(HttpWebRequest w)
{
// Set the keep-Alive to false, thus for not using it
w.KeepAlive = false;
// the second way
w.ProtocolVersion = System.Net.HttpVersion.Version10;
return w;
}
Thats it, now we have successfully disabled the KeepAlive feature
Posted in Labels: SCRUM |
Scrum is an agile framework for completing complex projects. Scrum originally was formalized for software development projects, but works well for any complex, innovative scope of work. The possibilities are endless. The Scrum framework is deceptively simple.
I am a highly motivated and enthusiastic developer. I dream to code something to touch the lives of billions!
I am keen sportsman and follow cricket. My passion for sport now takes a back seat to me looking after my two young children.
Check out Inforgraphic of my career!