Is the SilverlightFaultBehavior class required for Silverlight 4? - c#

MSDN says
Silverlight version 4 enables support for the Windows Communication
Foundation (WCF) SOAP fault programming model, which allows the
service to communicate error conditions to the client. In previous
versions of Silverlight, if an error occurred on the service, it would
register as an HTTP 500 response code and details about the error
would not be accessible to the Silverlight client.
However a number of other locations suggest using this still for Silverlight 4 clients and the above seems fairly ambiguous on what to do for Silverlight 4. I was wondering if anyone could confirm what approach should be used for handling WCF errors on Silverlight 4.

Yes, if you want to catch faults in a Silverlight 4 client, you will need to use a custom WCF behavior that changes that HTTP status code from 500 to 200 when a fault is raised by the service.
See: http://msdn.microsoft.com/en-us/library/ee844556(v=vs.95).aspx

There are two HTTP stacks in Silverlight, one provided by the browser (the default one) and a client stack, which is one written using the native OS stack. If you use the first one, you need to use the fault behavior to convert from 500 to 200 in the service. But if you use the client stack, you should be able to consume "normal" faults in SL.
More information about this at http://blogs.msdn.com/b/carlosfigueira/archive/2009/08/15/fault-support-in-silverlight-3.aspx.

Related

REST vs. SOAP for remote connection with PDA's

Some time ago, I designed an application to an exisitng system. The application allows updating some app in PDA's. It is a kind of a remote updater. It uses web service.
Before I designed the application I had read some articles about WCF - technology. Then, I found a piece of information about comparision between SOAP protocol and REST architecture. Then I understood that REST is more useful for devices such as mobile or PDA's. Because of REST requires less data than SOAP. Obviously, I read more about REST that it uses HTTP methods and I know a lot about it.
As a result, I decided to use the REST architecture and everything was good. The application is still using.
Recently, I have changed my job. There is an application which uses a web service to sending data to PDA's. The web service uses SOAP protocol. I was very surprised when I have seen it first time. In my job, nobody can't tell me about it with some reasons.
Summarizing my story, I need to know that I am right that REST is a better option for a web service when we need to connect with PDA's or both option are correct. I don't need some description between SOAP vs. REST. I would like to receive a precision answer.

How to return a custom http status code for SOAP faults

I'm creating a WCF SOAP web service using BasicHttpBinding.
Unforunately, this service will be accessed through a firewall that does not allow returning http status code 500 replies from the server to the client. Any such messages from IIS are replaced with a generic error page generated by the firewall.
Therefore, my only option seems to be to return my faults disguised as http 200 messages. The consuming clients are still under development and pretty flexible, so that shouldn't be an issue. What is the best way to accomplish this? Code examples would be much appreciated.
They are doing something similar here, but my service won't be consumed by Silverlight:
http://msdn.microsoft.com/es-es/library/ee844556(v=vs.95).aspx
As ErnieL wrote in his comment, http://msdn.microsoft.com/es-es/library/ee844556(v=vs.95).aspx (Creating and Handling Faults in Silverlight) turned out to be a perfectly good example for my case. I renamed the "Silverlight" parts to "Firewall" to better reflect my specific case.

CommunicationException; Store App -> .NET 4.5 WCF Duplex TCP Service; Instant Timeout

I am having trouble getting a Windows Store App to make calls into a WCF service.
The service is a Duplex service using a netTCP binding. The first time the client (A Windows 8.1 Store Application) uses the service, it throws an exception:
An exception of type 'System.ServiceModel.CommunicationException'
occurred in mscorlib.dll but was not handled in user code
Additional information: The socket connection was aborted. This could
be caused by an error processing your message or a receive timeout
being exceeded by the remote host, or an underlying network resource
issue. Local socket timeout was '00:09:59.9968452'.
This timeout is near-equal to my max, 10 minutes. The exception, however, happens immediately, and breakpoints in the service function are never hit. The two do seem to be talking at some level because altering the security protocol or the endpoint address cause other exceptions (security and connection as you would expect). I put a breakpoint in the service and the function I am trying to call never gets hit.
I have tried:
Ensure feature equivalence between Service and Client NetTcpBinding configurations
Raise timeouts, sizes (1-10 minutes for each, 10000000 for max sizes)
Ensure all passed object types are DataContracts with default constructors
Prayer; Considering a burnt offering
Any help would be greatly appreciated. New to WCF and having trouble finding help for the Windows Store / netTCP / Duplex targeted scenario.
If your Windows Store App client and WCF service are on the same computer and you're not running the Windows Store App client from inside Visual Studio, then you need to enable loopback communication. Check out this article:
http://msdn.microsoft.com/en-us/library/windows/apps/dn640582.aspx
At the very bottom it talks about the command line utility:
checknetisolation
Also, try making your method call as simple as possible with no return and no arguments. I know you said you checked all of the 'DataContract' attributes. But things can get tricky such as if you're using polymorphism and the base class doesn't have a 'KnownType' for a derived.

Log exceptions from .NET application to zabbix

I`m trying to accomplish this:
When an exception is generated on a webapp, i want to log the exception to zabbix via it`s api.
Browsing the api and the internet, i didn't found anything that could be helpful.
I do not want to use zabbix_sender, i just want to make POST calls to the api.
You can't use zabbix API to submit monitoring data. You need to use the same protocol used by zabbix_sender. If I remember correctly it is json based only in the latest versions of zabbix sever but you'd better off with zabbix 2.0 as minimum anyway. The protocol is TCP socket based sending, I can't say anything about .net but there are numerous implementations. For me the most useful one was this one in python.
Not sure I understood the problem. I would split it into 2:
1. Intercepting exceptions
2. Sending using Zabbix
I cannot help with the 2, since I'm not familiar with the "Zabbix". But if you need to intercept either all or unhandled exceptions you can register to the following AppDomain events:
AppDomain.UnhandledException
AppDomain.FirstChanceException
You can perform the registration in your initialization code (e.g. Global.asax):
AppDomain.Current.UnhandledException += (s, args) => ... // Send using Zabbix

System.ServiceModel.CommunicationException on overloading webservice

I am load testing my webservice
and get a
System.ServiceModel.CommunicationException
when I use 10 threads to communicate to it (without any sleep in between) - basically testing 10 conenctions at a time - through a windows application
An error occurred while receiving the HTTP response to http://localhost/XXX/XXXService.asmx. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Why would this happen and how to best resolve it
Also is this the way how asp.net application will interact with it too - is threading the best way to do the load testing
To begin with, you might want to try using WCF for new web services development. Microsoft now considers ASMX web services to be "legacy technology", and suggests that all new development use WCF.
Next, you might want to find out what happened. The exception isn't lying to you. There was an HTTP protocol error. You could look at the network traffic using Fiddler, to see what the problem is.
You might also look in the server event log.

Categories

Resources