Archive for the ‘Webservice’ Category

Need utils for fast testing of WCF or webservices?

SoapUI is a great tool for testing webservices (http://www.soapui.org/).

The built in WcfTestClient for VS Studio is another which works for both webservices as well as WCF services! It could be found under C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfTestClient.exe in VS Studio 2008.

Read Full Post »

One problem I encountered in a project is to call several services (Webservice/SQL etc) via BizTalk before delivering a result back to a web application. By calling the services synchronously and letting the user wait meanwhile is not a good solution, however calling the services asynchronously seems like a better choice.

By using AJAX and exposing the services as webservices from BizTalk a great solution could be made. I made a test webservice with the following code:

namespace WebApplication1
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = “http://tempuri.org/“)] //
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    public class WebService1 : System.Web.Services.WebService

        public string HelloWorld()
            return “Hello World”;

        public string HelloWorld2()
            return “Hello World2″;

Note the 5 seconds sleep in the HelloWord2 method. Then I created and AJAX enabled web page, with the following code:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”Default.aspx.cs” Inherits=”WebApplication1.Default1″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head runat=”server”>

    <script type=”text/javascript”>

        function pageLoad() {

        function MyBtn_onclick() {
            ret1 = WebApplication1.WebService1.HelloWorld2(OnComplete1, OnTimeout, OnError);
            ret2 = WebApplication1.WebService1.HelloWorld(OnComplete2, OnTimeout, OnError);

        function OnTimeout() {
            alert(“Timeout on webservice call”);

        function OnError() {
            alert(“Error in webservice call”);

        function OnComplete1(arg) {
            document.getElementById(‘MySpan2’).innerHTML = arg;

        function OnComplete2(arg) {
            document.getElementById(‘MySpan1’).innerHTML = arg;

    <form id=”form1″ runat=”server”>
        <asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
           <!– Add a reference to the webservice, to be able to call it from javascript code above –>
                <asp:ServiceReference Path=”~/WebService1.asmx” />
        <input id=”MyBtn” onclick=”return MyBtn_onclick()” type=”button” value=”Invoke” />
        <br /><br />
        <span id=”MySpan1″></span>
        <br />
        <span id=”MySpan2″></span>

When a user clicks on the Invoke button, the code invokes the both methods asynchronously. This means that the HelloWorld method returns its value before the HelloWorld2, even thought the HelloWorld2 is called before HelloWorld.

Read Full Post »