-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
服务调用 #24
Comments
已经注册了,请在网关修改 |
拉取最新代码? |
public static void TestForRoutePath(IServiceProxyProvider serviceProxyProvider)
{
Dictionary<string, object> model = new Dictionary<string, object>();
model.Add("user", new
{
Name = "fanly",
Age = 18,
UserId = 1
});
string path = "api/user/getuser";
string serviceKey = "User";
var userProxy = serviceProxyProvider.Invoke<object>(model, path, serviceKey);
var s = userProxy.Result;
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
} |
在客户端调用服务端的时候 发生错误给定的密钥不在字典当中不知是什么意思,服务端提示消息发送失败。 @fanliang11 |
Dictionary<string, object> model = new Dictionary<string, object>
|
不需要再JsonConvert.SerializeObject |
serviceProxyProvider.Invoke(model, path, serviceKey); |
不是这样的,在源码的demo中JsonConvert.SerializeObject 有这个也是可以调用成功,nuget上下载的,有没有JsonConvert.SerializeObject 都会报出这样的错误 |
因为不想去引用服务的dll,所以用serviceProxyProvider.Invoke(model, path, serviceKey)这种方式 |
贴下你的方法参数 |
ModuleName 设置的什么 |
ModuleName 设置的是Audit |
Dictionary<string, object> model = new Dictionary<string, object>
{
{
"entity", new
{
UserName = "simple",
Action = "testaction",
MentodName = "test",
MethodParams = "params",
OperatorIp = "127.0.0.1"
}
}
};
string path = "api/audit/insertAuditAsync";
string serviceKey = "Audit";
var userProxy = serviceProxyProvider.Invoke(model, path, serviceKey); 试试 |
ok,调用成功,感谢作者。这里实体的时候 字典的键 都必须是entity? |
记得点个赞 |
嗯呐,测试完了之后,会写个博客把踩了的坑 都写出来,大家一起学习。 |
serviceProxyProvider.Invoke(model, path, serviceKey);
我写了一个测试 在service.client
public static void Test(IServiceProxyProvider serviceProxyProvider)
{
Dictionary<string, object> model = new Dictionary<string, object>();
model.Add("UserId", "1");
string path = "api/user/getuser";
string serviceKey = "User";
想通过api 方式调用服务
服务端和客户端启动后
user返回的信息
返回的是自定义属性当中的?
The text was updated successfully, but these errors were encountered: