Check out my not-so-elegant solution on integrating ASP.NET and jQuery =P
Integrating jQuery and ASP.NET
It is possible to create multiple endpoints in WCF from one service contract declaratively (by declaring it in the configuration file), but it is also possible to do it programmatically (I think almost everything that can be done declaratively can also be done programmatically, but I’m not very sure about this one though).
Declarative settings
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <netMsmqBinding> <binding name="MyBinding" exactlyOnce="false" maxReceivedMessageSize="131072"> <!-- ... --> </binding> </netMsmqBinding> </bindings> <services> <service behaviorConfiguration="ServiceConfiguration" name="MyApp.MyService"> <endpoint address="endpoint_address1" binding="netMsmqBinding" bindingConfiguration="MyBinding" contract="MyAssembly.IContract" /> <endpoint address="endpoint_address2" binding="netMsmqBinding" bindingConfiguration="MyBinding" contract="MyAssembly.IContract" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceConfiguration" > <!-- Add the following element to your service behavior configuration. --> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration> |
You can specify as many endpoints as you want to each service here.
Programmatically
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <netMsmqBinding> <binding name="MyBinding" exactlyOnce="false" maxReceivedMessageSize="131072"> <!-- ... --> </binding> </netMsmqBinding> </bindings> <services> <service behaviorConfiguration="ServiceConfiguration" name="MyApp.MyService"> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceConfiguration" > <!-- Add the following element to your service behavior configuration. --> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration> |
Note that I removed the endpoints part. This is to ensure that the endpoints created are from my code, instead of my configuration file. Next is the ServiceHost creation, where I will define the endpoints.
MyService ms = new MyService(); ServiceHost svc = new ServiceHost(ms, new Uri("http://myuri.org")); svc.AddServiceEndpoint(typeof(MyAssembly.IContract), new System.ServiceModel.NetMsmqBinding("MyBinding"), "endpoint_address1"); svc.AddServiceEndpoint(typeof(MyAssembly.IContract), new System.ServiceModel.NetMsmqBinding("MyBinding"), "endpoint_address2"); svc.Open(); |
Best Regards,
Ferry Mulyono
I'm using WCF configured with netMsmqBinding, and I needed to send a message containing binary data (specifically for image file). When I tried to send a dummy message (i.e. new byte[] { 0, 1, 2, 3 } ), it worked, but when I tried to send a real image file (around 90 kb), it didn't work at all. When I checked the queue (MSMQ), it turns out empty, so I suspect my WCF ServiceHost already consumed the message, but still, why the message was ignored?
After doing *stupid* experiment by sending various sized binary message, turns out that it will ignore fields (in my case array of byte) sized over 16384 bytes (that is, 2^14). Please note that I was using the default configuration. But after doing experiments on various configuration, I found out that in the binding element, you can configure readerQuotas element.
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
In this case, I'm particularly interested in maxArrayLength attribute. Note that the size specified here doesn't relate to the overall message size, but only the individual field of the message. Turns out that the it refused to serialized any field sized over the specified size resulting in WCF skips the serialization of that particular message (bottom line, it ignores the message). So, what I did here is just specify the size, and it worked automagically.
For more information, check Security Considerations for Data
Best Regards,
Ferry Mulyono
This was my project for course "
Technique of Parsing and Translation" previous semester. It turns out that my group was the only group that was successfully utilizing .NET Platform, right from the lexer down to its code gen. Next tuesday my group will be invited as guest lecturer in the same course for my juniors. I've attached the executables if any of you are interested in low-level IL stuff; this could be a good start =)
"Alternative" to server side message inspector of WCF: WCF Client Message Inspector
Anyone have easier way to do it (View the SOAP message sent to service host in client side)?
Turns out Microsoft has acquired a company called SysInternals. They made really good Windows utility freeware.
Check it out: http://www.microsoft.com/technet/sysinternals/default.mspx
If you need low-level Win32 GUI touch in your WinForms app (such as simulating keypressed event to other controls), you might be interested in reading this =)
WndProc in .NET
I've been reading this nice book (Microsoft Visual C# 2005: The Language, Donnis Marshall).
It provides a great detail about the new language feature and the CLR itself inside-out. I haven't finished reading it yet, half-way done though :p. One interesting stuff is that “GarbageCollector” action isn't immediate, which of course contradicting what I knew at that time.
It turns out that GarbageCollector will determine the time, when is it appropriate to “release” the resources associated with an unreferenced object. However, there is a way to “persuade” GC to “work faster”, that is, by setting the object value into null. Probably this is the reason why there are some code on the internet, that set the object into null even thogh it's not used anymore. Because the book said that, by setting the object instance into null, GarbageCollector will move it to the top priority to release the resources.
Hi all, mgkn yg ini agak sedikit BasBang (klo kata Dondy :p). Tp ini gw baru ktemuin. Mgkn berguna utk yg suka coding rame2 tp males setup CVS/VSS gt. Jd mgkn utk yang uda ngerasain betapa susahnya copy-paste satu root project folder dan cari tau mana yang beda, tool ini bisa berguna.
WinMerge, and the best thing is it's FREE!!!
Feature paling keren yg gw demen disini itu dia bisa compare satu folder, dan dia akan compare smua isinya, dr folder (mgkn ada folder yg nambah ato berkurang), dan stiap file yg ada di folder itu.
Best Regards, Ferry Mulyono
Finally I got some time to work on the small documentation of my StealthObjectFactory. It's on http://www.codeproject.com/useritems/StealthObjectFactory.asp
Please take a look if you have some spare time :) Comments and votes are most welcome. Maybe you can share better solution (to the case described in the Background section).
Some result of my one-week time playing around with System.Reflection and CodeDom.
http://workspaces.gotdotnet.com/StealthObjectFactory
Brief Explanation:
Basically this is sort of tiny “framework” to enable performing factory pattern (i.e. create instance of a new object whose type is unknown at runtime, but the returned object complies with a contract, whether it's abstract classes or interfaces) by scripting means (no compile, no deploy, etc). But then again, as written in the GotDotNet Workspace, it's v,0.1 LOL :p So I've tested the code only using simple hello world project.
Hopefully it can help beginner's to .NET to understand about Reflection and Activator, and a little section handler on AppConfig (This is my first time too :o ). If there's any complaint, suggestion or anything, don't hesitate to contact me :)
Utk yang uda lama ngeblogs, mgkn tau klo kita akan migrate blogs ini menggunakan Community Server 1.1; Diharapkan pas launch tgl 29 Nov, uda kelar utk jd showcase :)
First of all, data dari blogs yang lama uda pasti gak bole ilank. So far test pake dummy data uda berhasil. So cross your fingers hoping that your data doesn't get erased, LOL. Tapi mgkn ada yang harus di-reset, seperti passwordnya. Karena sekarang blogs uda memuat lebih dari 2000 blogger, and it's impossible to reset each one of these manually, harap maklum :p
Anyway, more progress report coming up, especially H-1 to blogs migration at INDC Server.
Check out this link, it shows a glimpse of how cool will CS 1.2 be, and keep in mind that it's web application :)
http://scottwater.com/inksample/
Can't wait till it's release. Hopefully on December this year.
Wew, mgkn saya yang pertama ngepost ttg workshop ini neh, berhubung saya yang pertama kali sampe kampus. Joule mgkn akan begadang karena ada error yang sangat aneh. Jd begitu buat New Project (Windows C# Application) dan dijalankan, muncul exception ArithmaticOverflow, dan ini gak cuma di satu komputer, mgkn ada sekitar 4-5 kompie. Mgkn ada yang tau kenapa?? Saya jg sempet pucet pas ditanyain itu :p
Well, most of the audience is VB6-ers, so my suggestion is be very very clear about case-sensitivities, kita sempet bolak-balik handle error dari case-sensitivities. And another thing is theory doesn't work too good, maybe practice will be easier to comprehend :)
Good luck to Mr. Agung and Basyir on Day 2 and 3 :)
Another thing: ADO.NET should be covered from basic, because we kind of skipped that part, lol :p
Pas Community Star kmrn ini di Biotrop, mas Agung sempet membahas sebentar ttg DotNetNuke. Dan saya jg sempet nyobain install disono, tp gak bisa.
Nah, bagi yang bernasib sama, ini ada artikelnya utk install DotNetNuke 3.x :)
http://blogs.netindonesia.net/ferry/articles/5993.aspx
More Posts
Next page »