[英]I have set up a web service but have no idea how to get data from it in MVC 5 c#
我有以下用于Web服务的名称空间,并且可以看到很多可以访问的功能...
using MyService.api;
public class HomeController : Controller
{
public ActionResult Index()
{
//What needs to go here?
// LoginRequest and Response are types from the web service reference
LoginRequest loginRequest = new LoginRequest();
loginRequest.user = "blah";
loginRequest.password = "abc1234";
LoginResponse loginResponse = new LoginResponse();
string sessionID = loginResponseSession.session.sessionId; // This has nothing in it
return View("Index", sessionID );
}
...
api公开了所有这些方法,例如:
MachineRequest machineRequest = new MachineRequest();
string[] machines = machineRequest.machines;
但是,当然,当我这样称呼它时,它并不能神奇地从URL中收集机器。
如何提出并回应要求? 服务参考实际上是什么?
您的问题还不清楚。 如果已生成WCF服务参考,则可以使用“代理”或“客户端”,如下所示:
var client = new MyService.api.ApiReferenceClient();
var loginResponse = client.LoginRequest(loginRequest);
这将执行SOAP调用(或使用任何绑定)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.