Controllers/WebSvrController.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ServiceReference1;
namespace WebApplication1.Controllers
{
//[Route("api/Controller")]
//[ApiController]
[Serializable]
public class WebSvrController : ControllerBase
{
string _pc_name = System.Net.Dns.GetHostName().ToString().ToLower();
[HttpGet]
public string GetDptName(string user_id)
{
string address;
//创建绑定对象
var binding = new BasicHttpBinding();
//根据WebService的URL构建终端点对象,参数是提供的WEBSRV地址
if (_pc_name.ToLower().Contains("yu"))
{
address= "http://localhost:8087/Service1.asmx";
}
else
{
address = "http://localhost:8087/Service1.asmx";
}
var endpoint = new EndpointAddress(address);
//创建调用接口的工厂,注意这里的泛型只能传入接口 泛型接口的参数是WEBSVR里面定义的的类名+soap
var factory = new ChannelFactory<Service1Soap>(binding, endpoint);
//从工厂获取具体的调用实例
var callClient = factory.CreateChannel();
//调用具体的方法这里是getperson方法
Task<hr_hi_person> person = callClient.selectpersonforAsync(user_id);
//获取结果
return person.Result.cDepName;
}
[HttpGet]
public Inventory GetInventory(string cinvcode)
{
//创建绑定对象
string address;
//创建绑定对象
var binding = new BasicHttpBinding();
//根据WebService的URL构建终端点对象,参数是提供的WEBSRV地址
if (_pc_name.ToLower().Contains("yu"))
{
address = "http://localhost:8087/Service1.asmx";
}
else
{
address = "http://localhost:8087/Service1.asmx";
}
后面还有 25 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
