How to remove time info from WCF messages? - silverlight

I was trying to set maxclockskew for a secure service being consumed in a Silverlight client.
The things I tried have been summarized in related post
How to fix the WCF maxClockSkew problem in a HTTPS Silverlight application context?
As I also have found no way to do that, now I also want to remove the timeinfos, so that clock-skew validation is skipped. How is it done?
just setting the InclueTimestamp to false didn't work.

Related

.Net Windows Form Client. Capturing Request/Response SOAP from ASMX webservice

before i decided to post this question i went thru several articles and questions in here... none of those seem to be a solution for me.... or i am doing something wrong.
I went thru this article, suggested in this site
http://www.codeproject.com/Articles/38986/Trace-SOAP-Request-Response-XML-with-TraceExtensio?msg=4152902#xx4152902xx
that's not working. Not even the source code i downloaded.
then i found this other article...
http://blog.encoresystems.net/articles/how-to-capture-soap-envelopes-when-consuming-a-web-service.aspx
This is simple.
I have a client (winform)... interacts with a webservice i have no control over, and i need to be able to capture the soap request and response. i followed like 5 tutorials so far, soapextensions, soapattributes, etc, etc... nothing seems to work for me. i have modified app.config, done everything by the book... nothing.
Question... Does anyone have a WORKING example of this? the two examples i found don't work :)
I am using Visual Studio 2010.
Have you tried using tracing in the config file as described in the MSDN articles How to: Configure Network Tracing and Configuring Tracing?
Simply use a "Service Reference" instead of a "Web Reference" then see WCF Tracing.
SOAP extensions need to be registered on the service side (that's why all posts asking you to do configuration inside web.config).
If you want to print out the SOAP messages inside your WinForms client, you will have to call web service in the "raw" way,
http://mikehadlow.blogspot.com/2006/05/making-raw-web-service-calls-with.html
#James demonstrates System.NET tracing, which is another way to see the SOAP messages in an external log file, but that's only useful for troubleshooting, as you won't receive the tracing data inside your client.

How can I access a REST API through Silverlight (With basic auth)?

I'm trying to access a run-of-the-mill REST API through a silverlight application, but can't seem to get basic authentication to work (using silverlight 4.0).
I'm using a .NET WebClient, and setting the webclient.Credentials with a valid username/password (for the API).
I'm running into two main errors:
System.NotSupportedException: BrowserHttpWebRequest does not support custom credentials.
(this only occurs when I set the webclient.UseDefaulCredentials to false)
and
System.NotImplementedException: This property is not implemented by this class.
at System.Net.WebRequest.set_Credentials(ICredentials value)
(occurs when webclient.UseDefaultCredentials isn't set at all)
what am I missing here? Is basic auth still not supported in Silverlight 4.0?
There is an article about it here http://mark.mymonster.nl/2009/12/02/silverlight-4-credentials-weve-got-it/ and it seems the magic line is:
WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp);
In my case it seems to send the credentials, but I still end up with a 401 error but I just grabbed one of my web servers to try and it may not be configured correctly, but this seems like it should work.
I would also suggest trying the open source library Hammock for REST It provides a very useful wrapper around a lot of modern web calls like REST and oAuth.

Silverlight web service call not even hitting servers

I have a custom proxy class for a single WCF web-service (takes a string in, sends a string back). The asynchronous web service call works great from my Windows Form app. However, when I call it from a test Silverlight app I get an error: Hresult 0x80000012. This error is for Extension Attributes on files I believe... Go figure.
Using Fiddler I can confirm that no traffic is making it to IIS which is hosting the service, so it isn't the usual cross-domain restriction issue. I've tried using both "localhost" (which works in the Windows Forms app) and a name defined in my hosts file just in case "localhost" was causing the problem.
I've tested it by making the async call from the UI thread and also from a thread-pool queue item with the same results.
The proxy code is basically just simplified down from what the MS proxy generator creates, setting up bindings and settings programatically instead of via config files, and I use basically the same source to compile normal .Net and Silverlight versions of the libraries involved. (Now, the MS proxy code it is based on is from a WCF web service, not from the RIA template code, so maybe there are differences there...)
Four days of fruitless search on this one. Any help or suggestions would be wildly appreciated!
Figured it out. I was using (stupidly) a backslash in part of the URL that I used to set up the service call. Most of the interior parts of the MS code handled that ok and transposed them to forward slashes -- on Windows Forms everything worked seamlessly in fact. However, the Silverlight libraries couldn't handle it and threw the very helpful "HResult 0x80000012" error.
Changing my backslashes to slashes seems to have fixed the problem!

Using ASP.NET session state with Silverlight (PRISM)

The scenario:
I have a PRISM application developed in Silverlight (4), and I'm using a ASP.NET server side application to host several web-services (which, in turn, accesses WCF-services, but that's not really important here). The Silverlight application must be able to call the web services cross-domain (meaning that the web services isn't necessarily on the same server hosting the silverlight application).
The Silverlight application consists of several modules, each accessing the ASP.NET web-services.
I do not have much experience with Silverlight and PRISM, but as far as I can see, this is not a very unusual scenario...
The problem:
My challange is, that when 2 different modules access the web-services, I get 2 new sessions on the web-server. I would have thought that since both modules live on the same HTML-page (and then also in the same browser session), they would get the same session on the web-server...?
I have tried to make the web-service Proxy-client globally available in the container (using Unity), by registering an instance (using Container.RegisterInstance), and then getting this instance whenever a module needs to make a web-service call (using Container.Resolve), but this doesn't seem to help.
However, any calls made within the same module always gets the same session on the server.
Can anyone see what I'm missing here...?
Thanks!
Jon
Looks like I found my own answer.
The problem was that my application was firing multiple web-service calls upon startup (the different PRISM-modules working independently). And when several calls were made before any responses was given from the web-server, no session (and hence no "ASP.NET_SessionId" cookie was provided) back to the client before subsequent calls were made.
My solution was to make sure I make one call (async as always), for example to a simple Ping-like web-service, then hold all other calls to the web-server until this response is back. Then, all subsequent calls are given the same Session on the server (because now they all contain the "ASP.NET_SessionId" cookie in the header).
In pratice, this call is made by the PRISM-shell, and no modules are beeing loaded before I receive the reponse. Then I'm absolutely sure that none of the other modules get trigger-happy before I have a session-state on hand.
Still, if anybody sees any other problems with this solution, I'm more than happy to hear from you.
Thanks!
Jon

How to presist the user authentication in SL3 + RIA

I am developing SL3 + RIA services with custom authentication. I followed the example in
http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2661 to implement custom authentication.
Based on the implementation, you first do login request from client to service. This request is async process. Since login is async, the control will go back to GUI which then starts to do data bind in SL controls using RIA services, the services happens to requires the authentication to be successful (by adding [RequireAuthentication] attribute).
The trouble is, since you requested login might not have completed before the data binding starts t this stage the authentication is false because of that data binding will fail.
I would like to know if you require your web services to have 'RequireAuthentication' how would you wait for authentication to complete at the server side or client side. Appriciate the help.
Thanks,
Found the answer, the way I have designed the controls was the problem, instead of start binding the control, I moved it to start the binding after the login is successful solved the problem.*

Resources