samedi 29 octobre 2016

Creating Asynchronous XML Web Service Methods with .Net 1.1

I am working with Visual Studio 2003 and .NET 1.1. I created one web service method. After it works, I am trying to change it to Asynchronous XML Web Service Methods explicity. But I have no idea how to write and it is stuck. Please help me how to develop Asynchronous Web Service Methods for the following Web Service:

public class Service1 : System.Web.Services.WebService
{

    public DepositAuthenticationHeaders myHeaderVariable ;

    [WebMethod]
    [SoapHeader("myHeaderVariable")]
    public DepositAuthenticationResponse RedirectDeposit(string TransactionId, Amount amount, AccountInfo accountInfo)
    {
        string apiVersion = "";
        string sessionToken = "";
        string merchantId = "";
        string merchantPassword = "";

        string transactionId = "";
        string tranAmount = "";
        string tranCurrency = "";

        string accountId = "";
        string userName = ""; 

        apiVersion = myHeaderVariable.ApiVersion;
        sessionToken = myHeaderVariable.SessionToken;
        merchantId = myHeaderVariable.Credential.MerchantId;
        merchantPassword = myHeaderVariable.Credential.MerchantPassword;

        transactionId = TransactionId;
        tranAmount = amount.amount;
        tranCurrency = amount.currency;

        accountId = accountInfo.field1.Value;  //123456
        userName = accountInfo.field2.Value;    //TEST1

        DepositAuthenticationResponse resp = new DepositAuthenticationResponse();
        resp.RedirectUrl = Server.UrlEncode("http://www.aspmemo.net");
        resp.Status = "APPROVED";
        resp.ErrorDetail.Code = ""; 
        resp.ErrorDetail.Description = "";

        return resp;
    }
}

[Serializable]
public class DepositAuthenticationHeaders : SoapHeader 
{
    private string _ApiVersion;
    private string _SessionToken;
    private Credentials _Credential;

    public DepositAuthenticationHeaders()
    {
        _Credential = new Credentials();
    }

    public string ApiVersion
    {
        get 
        {
            return _ApiVersion;
        }
        set 
        {
            _ApiVersion = value;
        }
    }

    public string SessionToken
    {
        get 
        {
            return _SessionToken;
        }
        set 
        {
            _SessionToken = value;
        }
    }

    public Credentials Credential
    {
        get 
        {
            return _Credential;
        }
        set 
        {
            _Credential = value;
        }
    }

}

[Serializable]
public class Credentials
{
    private string _MerchantId;
    private string _MerchantPassword;
    private string _Credential1;
    private string _Credential2;

    public Credentials()
    {

    }


    public string MerchantId
    {
        get 
        {
            return _MerchantId;
        }
        set 
        {
            _MerchantId = value;
        }
    }

    public string MerchantPassword
    {
        get 
        {
            return _MerchantPassword;
        }
        set 
        {
            _MerchantPassword = value;
        }
    }

    public string Credential1
    {
        get 
        {
            return _Credential1;
        }
        set 
        {
            _Credential1 = value;
        }
    }

    public string Credential2
    {
        get 
        {
            return _Credential2;
        }
        set 
        {
            _Credential2 = value;
        }
    }
}

[Serializable]
public class Amount
{
    private string _amount;
    private string _currency;

    public Amount()
    {
    }

    public Amount(string strAmount,string strCurrency, string strAmt)
    {
        amount = strAmount;
        currency = strCurrency;
    }

    public string amount
    {           
        get 
        {
            return _amount;
        }
        set 
        {
            _amount = value;
        }
    }

    public string currency
    {           
        get 
        {
            return _currency;
        }
        set 
        {
            _currency = value;
        }
    }

}

[Serializable]
public class AccountInfo
{
    private Field1 _field1;
    private Field2 _field2;

    public Field1 field1
    {
        get 
        {
            return _field1;
        }
        set 
        {
            _field1 = value;
        }
    }

    public Field2 field2
    {
        get 
        {
            return _field2;
        }
        set 
        {
            _field2 = value;
        }
    }

    public AccountInfo()
    {
        field1 = new Field1();
        field2 = new Field2(); 
    }

    public AccountInfo(string name1, string value1, string name2, string value2)
    {
        field1 = new Field1(name1, value1);
        field2 = new Field2(name2, value2); 
    }

}

[Serializable]
public class Field1
{
    public string Name;
    public string Value;

    public Field1()
    {

    }

    public Field1(string name, string strValue)
    {
        Name = name;
        Value = strValue;
    }
}

[Serializable]
public class Field2
{
    public string Name;
    public string Value;
    public Field2()
    {

    }

    public Field2(string name, string strValue)
    {
        Name = name;
        Value = strValue;
    }
}

[Serializable]
public class DepositHeaders : SoapHeader 
{
    public string ApiVersion;
    public string SessionToken;
}

[Serializable]
public class DepositAuthenticationResponse
{
    public string RedirectUrl;
    public string Status;
    public ErrorDetails ErrorDetail = new ErrorDetails();
}

[Serializable]
public class ErrorDetails
{
    public string Code;
    public string Description;
}

I just created web service below and it is stuck.

[WebMethod]
public IAsyncResult BeginRedirectDeposit(string TransactionId, Amount amount, AccountInfo accountInfo, AsyncCallback callback, object asyncState) 
{

}

[WebMethod]
public DepositAuthenticationResponse EndRedirectDeposit(IAsyncResult asyncResult)
{

}

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire