Tools to generate WSDL from SOAP Sample?

I need to create client to web services that are documented by providing samples of SOAP messages, but there is no WSDL file available.

I’ve done  a Google search and bookmarked a few links, that can help:

XSLT that transforms from XSD to WSDL and related Spring Web Services(inJava)

Rick Strahl ‘s    Syncing up external WSDL Schemas with a stock .ASMX Web Service?

WSCF – Web services Contract-First, for real

soapUI is a free and open source desktop application for inspecting, invoking, developing, simulating/mocking and functional/load/compliance testing of web services over HTTP

 I also posted a question to webservices group.

I am going to check these links and a few others trying to find a tool to simplify WSDL creation.

Altova  XMLSpy® 2007 includes WSDL Editor and Documentation Generator .  but their Support replied me, that their tool does not have this facility.

I’ve considered to use XSD.EXE to generates an XML schema from an SOAP file and then use WSCF – Web services Contract-First, to generate WSDL from XSD, but my SOAP xml wasn’t acceptable for  XSD.EXE.

 

Advertisements

WaitAll to support calls from WindowsForms

We have multi-threading application that uses WaitHandle.WaitAll methods. It works fine, when called from ASP.NET, but when it is called from WinForms test harness, it causes the error “WaitAll for multiple handles on an STA thread is not supported.”. I’ve included the workaround and moved code to helper function.


However I needed to call the function with different parameters List<ManualResetEvent> and List<WaitHandle> . Even if ManualResetEvent is derived from WaitHandle, there is no implicit casting. Threads

Question regarding Generics and Inheritance and Casting List<> of derived class to List<> of base class? pointed me to ConvertAll method of List<> generic. And the article Introduction to anonymous methods in C#  helped me to use anonymous delegate to reduce code. 
The final helper class is shown below” 

 

public class ThreadingHelper

    {

        public static bool WaitAll(List<ManualResetEvent> eventList , int millisecondsTimeout)

        {//Casting List<> of derived class to List<> of base class? see http://www.thescripts.com/forum/thread276346.html

            //new Converter<ManualResetEvent, WaitHandle>(ConvertDelegate));

 

            //and http://www.theserverside.net/tt/articles/showarticle.tss?id=AnonymousMethods

            List<WaitHandle> waitHandles = eventList.ConvertAll<WaitHandle>( 

                    delegate(ManualResetEvent ev) { return (WaitHandle)ev; });

           return WaitAll( waitHandles, millisecondsTimeout);

        }

        public static bool WaitAll(List<WaitHandle> waitHandles, int millisecondsTimeout)

        {

            bool bRet=true;

            //to avoid “WaitAll for multiple handles on an STA thread is not supported.” SEE http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic28609.aspx

            //alternative solutions described in http://www.issociate.de/board/post/250510/WaitAll_for_multiple_handles_on_an_STA_thread_is_not_supported.html

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)

            {//usually happens when tested from TestHarness or NUnit

                foreach (WaitHandle handle in waitHandles)

                {

                    bRet |=handle.WaitOne();

                }

            }

            else

            {

                if (millisecondsTimeout > 0)

                {

                    bRet=WaitHandle.WaitAll(waitHandles.ToArray(), millisecondsTimeout, false);//

                }

                else

                {

                    bRet=WaitHandle.WaitAll(waitHandles.ToArray());

                   

                }

            }

            return bRet;

        }

 

    }

Reference to different database in “Database Mirroring” environment

We have a stored procedure in one database that (among other things) insert a row to another database on the same server -something like

INSERT INTO OtherDatabase.dbo.LogTable.

We are using “Database Mirroring”  feature of SQL Server 2005 having mirror on another server. However failover switch happens for each database separately and it can be situations, when one database run on the same principle server, but another switched to the mirror server. For this situation the mentioned above SP failed, and the design is not acceptable.

The recommended design is to keep all tables in the same database and avoid cross-database calls, Assumption that databases are always on the same server is not valid in “mirriring” environment.
To copy/syncronize data between databases use some replication/DTS procedures that are asyncronous to main transactions.

UPDATE: After writing the post I found that it is documented in MSDN: Database Mirroring and Cross-Database Transactions and in MS support KB Using database mirroring for cross-database transactions 

Ways to store bookmarks/favorites.

When I have a new task/project, it is often required to research existing solutions on internet.
Usually I do a Google search, open a few links, quickly browse them and want to save urls for future references.
 
The simple and convenient way is in IE create favorites subfolder for the project and save URLs as favorite.
However it has two disadvantages- 1. Favorites are stored locally on the computer and not easily shared between home and office or with collegues/friends. 2. You can’t add extra notes for the link.
There is a web FURL tool to create shared/private favorites, but UI is not user-friendly enough.
Update: I am using http://del.icio.us/mfreidge and it is acceptable, but not as simple as IE favorites  and not as flexible , as your own document with links and free format comments.(See also similar link-sharing  sites like DZone )
The best approach that I found is to create a Word document, copy and paste links that I consider interesting and add extra notes or group links as you wish.
Alternatively I am using Gmail drafts or Google documents to create the post, that is accessable from different computers and has autosave facility.
When finish the first draft, post it to blog and then it will be available for myself from other locations, as well as for others who is interested in the same topic. The examples of such notes are my posts My notes about MyGeneration Templates, Links for Code Generator/ and O/R mappers for ASP.NET application , Schedule/Calendar Asp.NET controls with Source Code,  ASP.Net Ajax UpdatePanel links.
 
I’ve noticed that Google recently added “Note this”(Notebook link to their search results, that looks quite good, but I didn’t use it yet.

No Copy Constructor support in .Net framework.

I have a base class with a lot of data members and I wanted to create a constructor in derived class, that will take a base class as a parameter and assign all data members values from the parameter:

class Derived: Base
{
    Derived(Base baseClass)
   {
      //Assign all data
    }
}

The function is almost like  Copy Constructor, so I tried to search Google for it.
There is a discussion on MBR IT/.NET 247 : how to implement a C# copy constructor .

where Jeffrey Tan from Microsoft Support suggested :
public extendeddatagrid(MyDataGrid obj)
{
this=obj.Clone() as DataGrid;
}

Unfortunately, it is not allowed to assign object to this in .Net.
I’ve also found a good article on
Windojitsu.com — Copy Constructors vs ICloneable. 

But .Net framework doesn’t have a facility to assign all members like MemberwiseClone Method does for copying.

So developer has to write code to assign all data members from passed object. It is quite annoying for big classes like I have.

The related topisc are discussed in article Copying, Cloning, and Marshalling in .NET

Update: See my post Implement Copy constructor using Serialization or Reflecton

Dynamic menu in ASP.NET 1.1.

My friend asked me, how to built dynamic 2 -lelels menu in VS 2003. Items coming from database amd mainly are hyperlinks to HTML document.

I haven’t written myself dynamic menu in ASP.NET.

My application was based on DotNetNuke and used DNNMenu See http://webcontrols.dotnetnuke.com/dnnmenu.aspx

However I am not sure, is it possible to use it stand-alone without DNN.

The author of DNNMenu Jon Henning had separate SolPart menu ,but unfortunately the link

In ASP.NET 2.0 there is standard Menu Control .

http://www.solpart.com/Default.aspx?tabid=132 seems not working any more.

Start Transaction from ASP.Net application can cause unexpected locks on the database.

I have the ASP.Net application, that uses SqlTransaction.BeginTransaction before the call to Update SP and commit after the call.If any exception would happened, transaction should be Rollback. 
The code snippet is the following: 
conn.Open();
using (SqlTransaction trans = conn.BeginTransaction())
{               
      try
      {    
            ds = SqlHelper.ExecuteDataset(trans, CommandType.StoredProcedure, SPName);
            trans.Commit();
      }
      catch (Exception ex)
      {
            trans.Rollback();
//Log the error
      }
}
We noticed that during update of web.config the ASP.NET appDomain was recycled (or restarted) and it seems that at the time transaction was left open(neither Commit nor Rollback). And it caused  timeout for all subsequent updates to the locked table.
I beleive that the best approach is to remove transactions from .Net code and implement them inside each SP.
It is a fair amount of t-SQL coding, but thanks to SQL Server 2005 TRY/CATCH feature it can be done  easier.
 See TRY...CATCH in SQL Server 2005: An Easier Approach to Rolling Back Transactions in the Face of an Error
The article Managing Transactions in SQL Server Stored Procedures suggests for simple batch statements that are known at compile time I tend to use stored procedures. However when I need to issue a series of atomic statements but I don’t know what statements will need to be executed, exactly, until runtime ADO.NET transactions should be used.
In MSDN the article “Improving .NET Application Performance and Scalability” suggests 
  • Use SQL transactions for server-controlled transactions on a single data store.
  • Use ADO.NET transactions for client-controlled transactions on a single data store.
  • Use DTC for transactions that span multiple data stores.

  •  
    Other related links:

    I found the  article Tips On How to Minimize SQL Server Blocking  very useful. In particular it pointed to the commands
    DBCC OPENTRAN and DBCC INPUTBUFFER ( session_id [ , request_id ] )