Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How to pass username password to webservice created with custom httpmodule (Basic Authentication)

$
0
0

hi !

I have created a web service and implemented Basic authentication using Custom HttpModule.

But don't know how to consume this Web Service (ASMX) in a C# Website (Serverside)

This web service has been tested using POSTMAN client by following way:

URL: http://localhost:24546/Service.asmx/DataPush

In Authorization Selected Basic Auth Entered Username and password

In Body checked raw and type as JSON(application/json)

sample data I passed as:

{"param":{"orderid":"Ord222","mobileno":"322223232","category":"cat9888"}}

I am following Stack overflow link http: // stackoverflow.com/questions/10861568/asmx-web-service-basic-authentication

Here is my Web method:

[WebMethod]
    [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
    public string DataPush(LeadParam param)
    {
        Response resp = new Response();

        string Result = "";
        string mPhone = "";

        mPhone = param.mobileno;

        if (mPhone == null || mPhone == "")
        {
            Result = "Blank Contact numbers are not allowed!";
        }
        else if (mPhone.Length < 10)
        {
            Result = "Invalid Phone!";
        }
        else
        {

              // Some Logic Here

        }
        resp.Message = Result;
        return JsonConvert.SerializeObject(resp);
    }

LeadParam Class:

using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;

	/// <summary>
	/// Summary description for LeadParam
	/// </summary>
	[Serializable]
	public class LeadParam
	{    public string orderid;
    public string mobileno;
    public string ticketid;
    public string category; }

Please Help!


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>