Click here to Skip to main content
15,891,839 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Guys,
I need to store first and last names in a sql table using wcf service with html page. Created Test Service and wrote data code in service layer. i tested it from rest client. it's working fine.
now i want to call the insert method in html page. How can i do this? i tried with website/web application. it's working fine but not for html.
Please help me to solve this

Thanks

What I have tried:

Created Test Service with first and last names and inserted those values from rest client.It's worked fine
Posted
Updated 5-May-16 5:55am
Comments
Sergey Alexandrovich Kryukov 5-May-16 11:12am    
Client-side script is not a suitable place for consuming WCF services directly. What do you have on server side? ASP.NET perhaps? Then it won't be a problem.
—SA

If it's a REST service then the fact that it is implemented by WCF is irrelevant, just google for articles on "call rest service javascript" and you'll find lots of examples

Getting Started · Consuming a RESTful Web Service with jQuery[^]
 
Share this answer
 
Please see my comment to the question — I strongly recommend not to try to consume services on the client side. You should better do it on the server side.

However, in case you have compelling reasons to do so (I doubt it), you can start with
Exposing WCF Services to Client Script[^] (still based on ASP.NET),
How To Consume WCF Using AJAX Without ASP.NET[^].

Note the Microsoft comment "This document may not represent best practices for current development". I think this note is very relevant on this page. :-)

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900