我对访问WCF的方式有疑问.我构建了一个安全的WCF服务,从数据库返回数据,它工作正常.现在我需要通过MVC访问这个Web服务(我对它没有足够的了解).
我在Stack Overflow上查了类似的问题,但是我找不到我需要的东西.我按照这个链接但是正如我所说,WCF从SQL返回数据,我用SQL连接我的WCF,当我使用这个例子时,我没有得到预期的结果.
我在MVC中调用的操作,它从SQL返回数据集类型
[OperationContract]
DataSet GetAllbooks(string Title)
Run Code Online (Sandbox Code Playgroud)
在Homecontrller的MVC我写道
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
public ActionResult Index()
{
DataSet ds = obj.GetAllbooks();
ViewBag.AuthorList = ds.Tables[0];
return View();
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我写道
@{
ViewBag.Title = "AuthorList";
}
<table>
<tr><td>ISBN</td><td>Author</td><td>Price</td></tr>
<%foreach (System.Data.DataRow dr in ViewBag.AuthorList.Rows)
{%>
<tr>
<td><%=dr["ISBN"].ToString()%></td>
<td><%=dr["Author"].ToString() %></td>
<td><%=dr["Price"].ToString() %></td>
</tr>
<% } %>
</table>
Run Code Online (Sandbox Code Playgroud)
我没有得到任何结果
此外,WCF提供的一些服务需要接受来自用户的输入我如何能够做到这一点
谢谢.