TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ravi sharma
NA
87
16.6k
Convert Service client to normal service
Sep 21 2017 9:11 AM
Hi,
I am accessing my wcf service method which returns List<Term> by using service reference in project. But as per changes in requirement, I need to access it direct via URL. I tried to convert by facing some issue.
Following method is needed to convert into normal service. Please suggest.
public JsonResult GetAllPriprities()
{
try
{
//Creating object of MessageHeader class to pass MessageHeader with client request
MessageHeader header;
//Creating object of OperationContextScope class
OperationContextScope scope;
//Creating object of EmpServiceClient to access WCF service methods
SDServiceReference.Service1Client objSDServiceReference = new SDServiceReference.Service1Client();
//Validating the user by passing Username and Password
string requestedFromURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
if (Common.Sessions.isServiceAuthenticated == "" || Common.Sessions.isServiceAuthenticated == null)
{
userToken = objSDServiceReference.UserLogin(requestedFromURL);
if (userToken != "" && userToken != null)
{
Common.Sessions.isServiceAuthenticated = userToken;
//defining scope
scope = new OperationContextScope(objSDServiceReference.InnerChannel);
//Creating the Message header
header = MessageHeader.CreateHeader("TokenHeader", "TokenNameSpace", userToken);
//Adding the created Message header with client request
OperationContext.Current.OutgoingMessageHeaders.Add(header);
//Request1- Calling GetEmpData() method to get record
var lstPriorities = objSDServiceReference.getAllPriorities().ToList();
return Json(lstPriorities, JsonRequestBehavior.AllowGet);
}
else
{
return null;
}
}
else
{
userToken = Common.Sessions.isServiceAuthenticated;
Common.Sessions.isServiceAuthenticated = userToken;
//defining scope
scope = new OperationContextScope(objSDServiceReference.InnerChannel);
//Creating the Message header
header = MessageHeader.CreateHeader("TokenHeader", "TokenNameSpace", userToken);
//Adding the created Message header with client request
OperationContext.Current.OutgoingMessageHeaders.Add(header);
//Request1- Calling GetEmpData() method to get record
var lstPriorities = objSDServiceReference.getAllPriorities().ToList();
return Json(lstPriorities, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
return null;
}
}
Reply
Answers (
0
)
Convertion from asp.net Webservices(asmx) to WCF(svc)
Service Refrence Error - netTcpBinding