"Contract first" involves creating the WSDL first and then using that to generate the code. There aren't many tools to do this.
Essentially, this approach involves modelling the messages, data and interfaces at the start and then publishing them as a contract before coding the implementation begins. Typically, modelling of the data and messages is done using a XML Schema (i.e. XSD files) and the contract is formalised using the Web Services Description Language (WSDL files).
thinktecture offer their free tool to do this which is nicely integrated with Visual Studio (2003 and 2005) and also allows a command line interface.
Get it from here.
Documentation and walk-through here.
Two MSDN articles which cover this are:
here and
here
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Monday, March 19, 2007
Monday, February 26, 2007
C# : Predefining an array
The classic way of creating an array is:
but a more elegant way is:
Enjoy!
Document[] doc = new Document[2];
doc[0] = new Document();
doc[0].code = "ABC";
doc[1] = new Document();
doc[1].code = "DEF";
but a more elegant way is:
Document doc1 = new Document();
doc1.code = "ABC";
Document doc2 = new Document();
doc2.code = "DEF";
? = new Document[] {doc1, doc2};
Enjoy!
Tuesday, January 23, 2007
C# : XML in a C# string
Note: "Left quote" replaced by #, "Right quote" replaced by ^
How do you do this? It has quotes, slashes etc. e.g.
string zzz = "#employees xsi="http://www.w3.org/2001/XMLSchema-instance"^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";
won't compile.
You could put a "@" in front to make it a verbatim string literal but it still won't compile.
The trick is to make each quote (") a double quote ("") e.g.
string zzz = @"#employees xsi=""^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";
which does compile.
Enjoy!
How do you do this? It has quotes, slashes etc. e.g.
string zzz = "#employees xsi="http://www.w3.org/2001/XMLSchema-instance"^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";
won't compile.
You could put a "@" in front to make it a verbatim string literal but it still won't compile.
The trick is to make each quote (") a double quote ("") e.g.
string zzz = @"#employees xsi=""^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";
which does compile.
Enjoy!
Thursday, January 11, 2007
Windows XP : cisvc.exe hogs the hard drive
My PC randomly just sat there with the hard disk light on but I wasn't doing anything - plus it was dog-slow.
Using the excellent Process Explorer, I discovered that the "cisvc.exe" program was the cause of the problem. This is part of indexing services.
My first solution was simply to suspend this via Process Explorer. (Right click on cisvc.exe). This helped but I had to do it every time on start-up.
So I googled and found one possible solution:
My Computer - right click on the C: drive - Properties - uncheck "Allow Indexing Service to index this disk for fast file searching" in the General tab.
This helped but the problem still remained.
Then I found another, better solution:
Control panel - Administrative Tools - Computer Management - expand "Services and Applications" - right-click on "Indexing Service" - "All Tasks -> Tune Performance". Then decide what level you want.
Enjoy!
Using the excellent Process Explorer, I discovered that the "cisvc.exe" program was the cause of the problem. This is part of indexing services.
My first solution was simply to suspend this via Process Explorer. (Right click on cisvc.exe). This helped but I had to do it every time on start-up.
So I googled and found one possible solution:
My Computer - right click on the C: drive - Properties - uncheck "Allow Indexing Service to index this disk for fast file searching" in the General tab.
This helped but the problem still remained.
Then I found another, better solution:
Control panel - Administrative Tools - Computer Management - expand "Services and Applications" - right-click on "Indexing Service" - "All Tasks -> Tune Performance". Then decide what level you want.
Enjoy!
Tuesday, December 19, 2006
Unix : Exporting a schema / stored procedure packages
Often you need to update the stored procedure packages for a schema.
So you laboriously export them via DDL and pretty them up and then run them on the target schema and then commit them.
Sometimes it's just easier to export the schema as an Oracle dump (which includes all the related stored procedures) and then import them on the target schema.
An example of the export command is:
exp login/password@schema file=target file directory/export name.dmp
Enjoy!
So you laboriously export them via DDL and pretty them up and then run them on the target schema and then commit them.
Sometimes it's just easier to export the schema as an Oracle dump (which includes all the related stored procedures) and then import them on the target schema.
An example of the export command is:
exp login/password@schema file=target file directory/export name.dmp
Enjoy!
Friday, November 10, 2006
Unix : Libraries in an executable
A useful command to do this is:
ldd executable name
This will list out all the libraries required by that executable.
Enjoy!
ldd executable name
This will list out all the libraries required by that executable.
Enjoy!
Monday, November 06, 2006
Misc : Folder / file comparisons with hard drive and FTP
I frequently have problems comparing folders on my PC with folders on a machine that is accessible mainly by FTP.
An excellent tool for this is Beyond Compare which allows all combinations of local driver and FTP including FTP to FTP.
Also allows custom compares so you could create a preprocessor to do some manipulation before the actual compare.
A massive time saver.
Enjoy!
An excellent tool for this is Beyond Compare which allows all combinations of local driver and FTP including FTP to FTP.
Also allows custom compares so you could create a preprocessor to do some manipulation before the actual compare.
A massive time saver.
Enjoy!
Misc : Formatting code in your blog
One possible solution is to use the
==blockquote==/blockquote==
construct
e.g.
void method (int a)
{
==blockquote==
==/blockquote==
}
where the "==" stands for the angled brackets.
Enjoy!
==blockquote==/blockquote==
construct
e.g.
void method (int a)
{
==blockquote==
int b = a * a;
==/blockquote==
}
where the "==" stands for the angled brackets.
Enjoy!
Friday, October 20, 2006
Unix : Finding files that start with a .
The classic "ls -l" doesn't show you any files that start with . (which is legal) (e.g. .param) and which are effectively hidden.
You need "ls -al" to ferret out these elusive beasts.
Enjoy!
You need "ls -al" to ferret out these elusive beasts.
Enjoy!
SQL : Comparing VSS stored procedures with the DB
This is a right royal pain. You have to extract every .pkg and .pkb manually e.g. if using SQL Navigator you right click, Extract DDL and save.
But how do you ensure that VSS is up-to-date?
An easy way is to right click on the heading e.g. right click on Package Bodies and then Extract DDL from here. What you are doing is creating one DDL file that contains ALL the package stored procedures.
In VSS, however, each package is stored individually. To combine them, DOS comes to the rescue! Use the copy construct "+".
e.g. copy a + b + c d.
This concatenates a, b and c and puts them in a file called d.
Now you can compare the combined DDL extract with the concatenated file from VSS.
But wait, there's more!
Part of the DDL extract puts the date on the extract and the tnsname that you use to access the DB. Different developers may have different tns names. So you need to remove these lines. This can be done very simply by writing a program to parse the file and create a new one without these lines.
e.g. in C#, something like:
(where the command line is something like 'Program 'input file' 'filtered file'')
static void Main(string[] args)
{
}
So the batch file would be:
copy concatenate statement
run filter on concatenated file
run filter on saved DDL file
compare the two filtered files
You could use something like Examdiff which is free to do the compare in which case the batch file line would be:
start ExamDiff.exe File1 File2
Enjoy!
But how do you ensure that VSS is up-to-date?
An easy way is to right click on the heading e.g. right click on Package Bodies and then Extract DDL from here. What you are doing is creating one DDL file that contains ALL the package stored procedures.
In VSS, however, each package is stored individually. To combine them, DOS comes to the rescue! Use the copy construct "+".
e.g. copy a + b + c d.
This concatenates a, b and c and puts them in a file called d.
Now you can compare the combined DDL extract with the concatenated file from VSS.
But wait, there's more!
Part of the DDL extract puts the date on the extract and the tnsname that you use to access the DB. Different developers may have different tns names. So you need to remove these lines. This can be done very simply by writing a program to parse the file and create a new one without these lines.
e.g. in C#, something like:
(where the command line is something like 'Program 'input file' 'filtered file'')
static void Main(string[] args)
{
string readBuffer = "";
int gIndex = 0;
int fIndex = 0;
if (args.Length != 2)
{
Console.WriteLine ("\nFormat is Prog 'input' 'output'");
System.Environment.Exit (0);
}
try
{
FileStream readStream = new FileStream (args[0], FileMode.Open);
StreamReader fileRead = new StreamReader (readStream);
FileStream writeStream = new FileStream (args[1], FileMode.Create);
StreamWriter fileWrite = new StreamWriter(writeStream);
while (fileRead.Peek () >= 0)
{
readBuffer = fileRead.ReadLine();
gIndex = readBuffer.IndexOf ("-- Generated");
if (gIndex == -1)
{
string tempReadBuffer = readBuffer.ToLower();
fIndex = tempReadBuffer.IndexOf ("-- from 'a specific DB string'");
if (fIndex == -1)
fileWrite.WriteLine (readBuffer);
}}
fileRead.Close ();
fileWrite.Flush ();
fileWrite.Close ();
}
catch (Exception e)
{
Console.WriteLine("Error : {0}", e.ToString());
}
}
So the batch file would be:
copy concatenate statement
run filter on concatenated file
run filter on saved DDL file
compare the two filtered files
You could use something like Examdiff which is free to do the compare in which case the batch file line would be:
start ExamDiff.exe File1 File2
Enjoy!
Tuesday, October 17, 2006
Visual Studio : Errors in the output
Quite often when you are doing a build of a large project, the build will fail when some VS utility returns an error. The problem is that you can't see why it fails.
A useful technique is to use the VS command prompt (Start - Programs - VS 2005 - VS 2005 Tools) and cut and paste the command line that failed from the VS output window.
Then execute it - you'll see all the errors.
The other option is to select Tools - Options - Projects and Solutions - Build and Run and change the build output verbosity to "Detailed" or "Diagnostic". Just change it back afterwards or you'll be swamped!
Enjoy!
A useful technique is to use the VS command prompt (Start - Programs - VS 2005 - VS 2005 Tools) and cut and paste the command line that failed from the VS output window.
Then execute it - you'll see all the errors.
The other option is to select Tools - Options - Projects and Solutions - Build and Run and change the build output verbosity to "Detailed" or "Diagnostic". Just change it back afterwards or you'll be swamped!
Enjoy!
Subscribe to:
Posts (Atom)