错误描述:
“由于 ContractFilter 在 EndpointDispatcher 不儿还,因此 Action 为http://tempuri.org/llnStoreReceiveGoodsService/PingZhengSave"的消息无注在接收方处理。这可能是由于协定不匹配(发送方和接收方 Action 不配)或发送和接收方绑定/安全不匹配。请检齐发送方和接收方是否具有相同的协定和绑定(包括安全要求,如 Message、 Transport、 None).”;
这是由于原项目中,上传功能写在了另一个解决方案的项目中,所以服务也需要迁移,我把按钮功能迁移到当前解决方案的项目中,重写了代码以及服务。
旧上传功能代码:
//1.1 添加图片到服务器路径
var re = System.Convert.FromBase64String(item.Photo);
var shpzPath = Configuration.GetSection("ReceivePingZheng:Path").Value;
if (!Directory.Exists(shpzPath))
{
Directory.CreateDirectory(shpzPath);
}
using (FileStream fs = new FileStream(System.IO.Path.Combine(shpzPath, guid.ToString() + item.FileExtension), FileMode.Create))
{
using (BinaryWriter binary = new BinaryWriter(fs))
{
binary.Write(re, 0, re.Length);
}
}
旧上传服务(写在专门给当前项目提供服务的json文件中):
"ReceivePingZheng": {"Path": "E://zjd", "ServerUrl": "http://192.168.80.33:8081" }
新上传功能代码:
//2.1遍历明细添加图片
var re = System.Convert.FromBase64String(item.Photo);
var shpzPath = ConfigurationManager.AppSettings["ReceivePingZheng"];//获取具有指定键的配置子节
if (!Directory.Exists(shpzPath))
{
//在指定文件中创建目录
Directory.CreateDirectory(shpzPath);
}
using (FileStream fs = new FileStream(System.IO.Path.Combine(shpzPath, detailID.ToString() + item.FileExtension), FileMode.Create))
{
using (BinaryWriter binary = new BinaryWriter(fs))
{
binary.Write(re, 0, re.Length);
}
}
新上传服务(写在web.config中):
<add key="ReceivePingZheng" value="E://pzsc" />
- 获取配置项请见之前博客
因为我修改了ReceivePingZheng凭证服务,所以当我自己运行的时候没有问题。但将客户端打包让别人使用时就会出现以上报错的问题,我们需要将本地server服务打开供其他人访问。也就是svc的地址
解决办法:
1、将提供服务的项目打包发布
(将提供服务得web打包)
2、在iis中配置网站,将打包好的web发布在iis上,并启动网站
3、在iis中浏览发布好的网站,让它在浏览器中运行就可以了