I just got started intercepting requests to my WCF service.
I'm calling the web service with java code that looks like this ( short version )
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Username", "Testname");
I'm receiving the request but I cant get/find the headers in the message request. I've tried something like this:
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
{
int headerIndex = request.Headers.FindHeader("Username", string.Empty);
var username = request.Headers["Username"]
return null;
}
But I always end up with -1 or exceptions. What is the right way to do this? Am I doing it wrong on the Java side as well?