WSS 2003 on ASP.NET 2.0

WSS 2003 on ASP.NET 2.0

I got this error in my WSS site that I am trying to upgrade to ASP.NET 2.0.


Error 
This Windows SharePoint Services virtual server has not been configured for use with ASP.NET 2.0.50727.42. For more information, please refer to Knowledge Base article 894903 at http://go.microsoft.com/fwlink/?LinkId=42660.


The resulting link is indeed very informative about what changes are required in the web.config to support the new security features of ASP.NET 2.0.


However, the stsadm -upgrade syntax that is mentioned in the article didn’t work for me.  I made the changes to the web.config file manually and everything works fine now.



 

Routing All Failed Messages in BizTalk 2006

Routing All Failed Messages in BizTalk 2006

When I was at Tech Ed in Boston in June I spoke to Lee Graber (Developer Lead for the BiztTalk Core Engine) about how you would go about sending all routing failures (messages without subscribers) to a send port so that a copy is readily available.  He showed me a quick demo that was pretty cool.  Here are the steps to complete this simple demonstration:


1.  Create any old receive port, making sure you check “Enable Routing For Failed Messages” as below:




2.  Create a Send Port with a filter ErrorReport.FailureCode = “0xc0c01680” (this is the code for routing failures, like the ones you see in Event View and HAT that say “Can’t find a matching subscription for the message“)



Test it by dropping any old message (where there is no port or orchestration expecting a message of that type) on the receive port and watch it appear out the send port.

BizTalk 2006 SQL Adapter problem

Breaking News – July 29 2006 – Microsoft has released a supported hotfix for this issue but you must contact microsoft support services to obtain it.  The hotfix is supported but is not published on the support site because it has been classified as “confidential“. Refrence the KB article 918316  to obtain the fix


Applications that worked well under BTS 2004 may experience problems under BTS 2006 because of an apparent problem in the new SQL Adapter.   The error usually happens when you are expecting multiple rows/messages back from a SQL port.  The error looks something like the following.






Exception type: WrongBodyPartException
Source: Microsoft.XLANGs.BizTalk.Engine
Target Site: Void ReadMessageState(Microsoft.XLANGs.Core.Envelope, Microsoft.XLANGs.BaseTypes.XLANGMessage)
The following is a stack trace that identifies the location where the exception occured
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.ReadMessageState(Envelope env, XLANGMessage msg)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.ReceiveMessage(Int32 iOperation, Envelope env, XLANGMessage msg, Correlation[] initCorrelations, Context cxt, Segment s)
at CB.MMAHH_File.Orchestrations.CBHHDownloadStore.segment2(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)


There is a hotfix being developed for this issue, but it is currently (as of time of writing) in pre-release and you have to contact microsoft for it. The KB number to reference is 918316 (Which does not seem to show on the MS Site yet). The file name is 273599_ENU_i386_zip.exe.


I would just give you a link but that might do more harm than good becuase the hotfix is not fully tested.  If you desperately need it and MS just can’t seem to get it to you, contact me and I’ll see what I can do for you.

Processing Binary Documents Through BizTalk Via Web Services


Just finishing up a two-week BizTalk Proof of Concept where I demonstrated an easier way to manage B2B interactions between a large insurance company and their vendors. This post is focused on one part of the solution that accepts binary messages via web services, and uses BizTalk to extract the message and send to SharePoint.


Instead of using DIME or MTOM, this company exposes a web service where the vendor puts a binary blob into a web service message element. So how did I match this requirement? First, I started with the XML schema for the service interface. Instead of holding a binary node, my DocumentContent node holds a string (base64).


The most important step came next. How do you actually turn this string value back into a binary format to be consumed by BizTalk? I created a class (referencing Microsoft.XLANGs.BaseTypes) containing an implementation of the IStreamFactory interface. The class constructor takes in the base64 string and saves it into a member variable. Then, I implement the required CreateStream method which takes my value and returns a stream of bytes. CreateStream is used when inflating the message part to be sent to BizTalk. The entire class looks like this:

/// <summary>
/// Class which implements XLANG IStreamFactory and lets us define any content
/// to turn into a message. In this case, a string is converted back to binary format
/// and returned in the stream.
/// </summary>
public class MyStreamFactory : IStreamFactory
{
private string messageContent;

public MyStreamFactory(string inMessageContent)
{
messageContent = inMessageContent;
}
#region IStreamFactory Members
public System.IO.Stream CreateStream()
{
byte[] messageBytes = Convert.FromBase64String(messageContent);

return new System.IO.MemoryStream(messageBytes);
}

#endregion
}


The next step was to create an object called from my orchestration that would take this string in, and return the required XLANGMessage back. I created a simple method which takes the inbound string and creates an XLANGMessage using the StreamFactory created above. That class looks like this:

/// <summary>
/// Method to call to generate XLANG message
/// </summary>
public class MyMessageCreator
{
public void CreateMyMessage(XLANGMessage outMessage, string binaryStringMessage)
{
outMessage[0].LoadFrom(new MyStreamFactory(binaryStringMessage));
}
}
Note that I’m setting the first message part of outMessage and using the LoadFrom method.


Back in my orchestration, I have an atomic scope within which I include a variable of type MyMessageCreator. I created a message of type System.Xml.XmlDocument to hold the binary attachment. Remember that a message of this type can hold *anything* as long as you don’t try and validate it or do XPath on it. So this will be the message I pass into the CreateMyMessage method as the output parameter. The message assignment shape’s code looks like this:

//dummy content setup
VendorMessageDocument_Attach = VendorMessageDocument_Response;

messageCreator = new Customer.POC.FraudDetection.Helper.MyMessageCreator();
messageCreator.CreateMyMessage(VendorMessageDocument_Attach, VendorMessageDocument_Response.DocumentContent);

As you see from the top line, I had to set my “binary document” message equal to something else, just to instantiate it. That value will get overwritten by the subsequent call to CreateMyMessage.


So, after this part of the orchestration, I now have a valid BizTalk message with which to send to a port, which in my case, is a SharePoint library. What I haven’t shown yet is HOW to send this document to BizTalk the first place. I exposed this orchestration as a web service, first of all. After referencing this service from my ASP.NET page, I created an instance of the service class, the input document class, and went about taking the selected binary file (Word doc, PDF, Excel, whatever) and adding it to that document message. My code is as follows:

BinaryReader r = new BinaryReader(docUpload.FileContent);
byte[] docBytes = r.ReadBytes(Convert.ToInt32(r.BaseStream.Length));
string convertedText = Convert.ToBase64String(docBytes);
r.Close();
//add this now-formatted base64 string to the web service message payload
doc.DocumentContent = convertedText;

I submit that message, and we’re on our way! So as I’ve shown, you can accept random binary content within a message payload itself (sans attachment), create a valid BizTalk message which contains that binary content, and send it out. Sweet. Now I could easily enhance this by accepting binary content vs. strings, or doing the processing in a pipeline vs. the orchestration. Maybe later 😉


Technorati Tags: BizTalk

Regular expression for Time of day

I recently tried to validate a time input on an ASP.NET form and I didn’t manage to find a good regular expression on the net for the times I was trying to validate.  I call these “natural times” becaues it’s the way that most north americans write time. (12 hr clock, with : and whitespace separators). This won’t take UTC dates or 24 hr times that I know of but it works well (so far) with the .Tostring(”t”) short time representation of times.


((1+[012]+)|([123456789]{1}))(((:|\s)[0-5]+[0-9]+))?(\s)?((a|A|p|P)(m|M))


It seems longer than necessary (they always seem to), but it’s pretty forgiving for the user typing the time.I won’t take the time to explain all of the features of the expression but you can use the following links to help test it out.



  1. My favorite regular expression testing site.
  2. Regular expression reference site.

Regular expressions are one of those things that you run into often enough that you need to know them, but not often enough that you ever really get good at them.  So each time we struggle to get back in that mindset and then do some trial and error to get through the expression development.  I’m keeping this on my blog mostly for my own sake, so that I have it again when I need it. 


But feel free to lift it and give me feedback.

What it takes to be a good software developer

Last week I’ve got such a message from my blog:



—–Original Message—–
From: sandusergiu1984@…
Sent: Thursday, June 29, 2006 1:17 AM
To: Eldar Musayev
Subject: (Random Thoughts and Hints on Software Development) : Hello Eldar!
Importance: High


Can you please tell me what I should learn to be a good software developer? Thank you.


Hm-m-m, tough question. No, seriously. A lot of people proud of being asked about such fundamental thing would gladly go ahead and give a ton of well, you understood what I meant. Anyway, I did not want to do that. If I give an answer, I want to give a real answer, at least as good as I can. So, I postponed answering until I can find the time to give my thoughts on the subject. And, please, understand, these are just my thoughts; there is a lot of other very qualified and decent developers who may have a different opinion.


“Sometimes it’s almost as good as sex”


So, IMHO the first qualification for a good developer is that he or she should enjoy writing the code. As one of the famous hackers of the past said before “Sometimes it’s almost as good as sex”. Actually, I suspect that this is exactly the sentence that made him famous. But anyway, that’s what I am talking about. Let me explain why.


First, software development is a very demanding field. It’s not a 9 to 5 job by definition. Of course, you and your manager should try to keep it 9 to 5 (meaning not policing you to come at 9am, but rather trying to prevent you from staying late and sustaining yourself on company-bought pizzas while fixing the code around the clock), but – alas! – that’s not always  possible. You simply cannot do a good job if you don’t really love to write and handle the code. Otherwise, a couple of milestones or releases and you will hate the job. So, you simply have to enjoy this work to be able to do it long enough. Sure, some do that long enough without, but we are talking about good software developers, right?


Another reason is learning. This is a profession where you have to learn, learn, learn without any breaks forever. Software development defies scientific management of Taylor invented early in the XX century to destroy trade unions of skilled workers like arsenal workers. The very idea of the “scientific management” may be shortly expressed as “look at what those smartasses do, decompose it into simple steps, hire a bunch of cheap dumb guys, teach them the same steps, fire smartasses.” In late 50s “the father of American corporate management” Peter F. Drucker discovered a completely new category of workers whom he called “knowledge workers”. Knowledge workers defy the power of “scientific management”. The problem with knowledge workers is that they know what to do themselves. What’s worse, if you try to decompose what they do, then by the time you teach a bunch of dumb guys the same thing, they already do something different. They know what’s needed, you – the manager – don’t. That’s a challenge for both the manager and the worker. Software development is the prime example of knowledge workers. As a software developer, you have to learn all your life non-stop. There is no break, no finish line, that’s a race to the horizon. Try to learn all your life the things that you don’t like, and you may end up in a mental institution. And if not, you’ll hate your life for sure. You have to love writing code.


There is also a third reason. Did you ever met a person who thinks that he is a great writer, but writes a louse fiction. He annoys his friends and relatives, editors, and simply cannot get where he wants. He does not improve. Beside being  oblivious to his own shortcomings, such guy has a really hard time getting an informative honest feedback on his job. Friend and family lie to him, saying that he does a great job just to be nice. Editors simply reject his manuscripts. How can he learn? We, humans, need immediate feedback to learn effectively. That’s how our neural circuitry works and learns.


Fortunately for us – software developers – computers are much more critical and at the same time more willing readers than whom you can find in a literature field. Sometimes mere milliseconds are required to get your bugs in your face, when your code executes. This is not always pleasant, but it provides the necessary continuous feedback into the neural networks of our brains getting them into the shape to become able to create programs.


Computers are ruthless in exposing defects in your craftsmanship, they don’t care for your ego, they don’t let you save the face, they simply don’t care: they execute exactly what you ordered, and if you ordered a wrong thing, that’s what is going to happen and that’s what everybody will see. Actually, this is very good for us, this helps us to perfect and learn. “Everything that does not kill us, makes us stronger”, but unless you really love writing code, this kills your will to continue.


That’s why you have to enjoy writing the code. That’s why enjoying writing the code is the first requirement for being a good developer.


Of course, everything can be at extreme. A typical hacker enjoys writing code a little too much. Computer and coffee is all he wants in his life. Those guys can never become good software developers because beside the desire to write code, you also need a desire to write good code, a code that other people will use (and hacker doesn’t care for other people). Fortunately, most people pass this phase and come to their senses, often at the same age when raging hormones start to balance better and find other channels for exit.


Technical side


Of course, beside the attitude, there is simply a technical side, skills. You have to learn a set of basic knowledge and skills to start. However, this is not that hard question. Just look at computer science curriculum of a good university, that’s it. Those professors are experts in the area, they know what to teach a student. Don’t invent a bicycle, just look at what they teach.


Of course, college differs form a college and a university differs from a university. Some make a better job, some are not. I am far from endorsing any particular university or a college, but in my humble opinion University of Waterloo in Canada makes a superb job teaching their students computer science and software development. There are other universities in United States and Canada that make as great job teaching their students. Examples include MIT and University of Alberta. If you want a more complete and worldwide list, check ACM competition site here: http://icpc.baylor.edu/icpc/Finals/ And, of course, I am personally fan of my own Alma MaterSt.Petersburg State University in Russia, that ranked 6th in 2006, but was first on multiple occasions in previous years.


Anyway, once you like the field, learning is much easier.


More to it


Still there is more to it. I hardly can give a complete list but here are a few examples:


– ergonomics, usability, perception psychology Should this button be red or gray? How much space menu should take on the screen? How many items can you put into a scroll box? Why actionable control should be visually different from indicators? These are all not the questions about the technical side, but about human ability to handle it.


– What is the main language for the programmer? English (or whatever you use in the office). Communication skills are very important part of software development. Negotiation skills – depending on a team – may be of an utmost importance. Sometimes, either you can convince the team to go your way, or those who cannot write code but skillful at negotiations will have it their way, and you will be stuck with fixing impossible bugs and infinitely patching your code (those guys usually lack the design skills too).


– Psychology, empathy and investigation/interrogation skills. How do you find out what exactly the customers expect from your programs? Even if you have a real customer in front of you, people in sales, marketing and executive positions (who often represent a customer for you) are not cured with the brutality of computers that train you to tell truth, truth and only truth, because any lie (bug) immediately blows into your face, even if you believed it yourself. Actually, they are often trained by superiors and peers in rather opposite things. Sometimes you can meet a customer who can vividly articulate what he wants, and that’s your lucky day. Unfortunately, in many cases you have to dig out the truth, which is not easy. And that’s in the case when you have a customer in the first place.


– And what if you don’t have customers yet? What if you develop a new revolutionary product that nobody (including competition) have thought about before? Of course, you have a business concept by that time, but how do you fill the blanks? A serious help may be marketing – by the way, marketing guys, at least at Microsoft, are great: they are smart, know what they are want and have a sixth sense at what the customer needs. But your marketing guy cannot fill all the blanks too. What it boils down to is that you have to have tons of common sense to make the right decisions. And some marketing knowledge does not hurt too. Understanding how a product for X-ers should differ from a product for Y-ers may be essential. By the way, do you understand this difference?


– Networking, and I don’t mean TCP/IP. Friends, keeping connected, socialized is very important in our profession. I am not very good at that myself, but even so more than half of my jobs in US (including internal transfers at Microsoft) came from networking and referrals from my friends. If you really good at networking, you may need no resume at all. Beside that, it gives you more. How do you track what’s new and worth attention around? Trade magazines usually have no clue, and even when they have, they are still filled with tons of paid ads junk. Friends are your source of upcoming technology alerts, no-bull overview and introduction to new things.


– and that’s not all Feel free to add your thoughts at what is needed for a good software developer in the comments to this post.


So, I am wondering, if I managed to answer the question? I don’t know. I tried my best, if you can do better, do so and leave a link in the comments.