C#调用EAS webservice 报错基础连接已经关闭

最近在做业务系统与EAS进行财务功能集成项目时,系统集成接口调用时出现以前未遇到过的问题

1. 项目环境

系统 技术平台 系统版本 接口方式
业务系统 .net / C# - webservice
EAS java V8.2 webservice

2. 问题描述

在业务系统通过visual studio服务引用功能引用eas webservice,例如:http://100.100.100.100:6888/ormrpc/services/EASLogin?wsdl

然后webservice调用示例代码如下:

ConsoleApp2.EASLoginProxyService proxy = new ConsoleApp2.EASLoginProxyService();
ConsoleApp2.WSContext context = proxy.login("tanze", "", "eas", "A001", "L2", 0);
Console.WriteLine("sessionId : " + context.sessionId);
Console.ReadKey();

在执行webservice接口调用时,报错: 基础连接已经关闭: 连接被意外关闭。

3. 问题分析

金蝶的这个接口的http 1.1, C#引用服务自动生成的是http 1.0
由引用方和目标服务接口协议不一致,导到webservice调用失败。

4. 解决方法

在调用webservice前设置

System.Net.ServicePointManager.Expect100Continue = false;

修改 http1.1 协议存在的问题
示例代码如下:

System.Net.ServicePointManager.Expect100Continue = false;
ConsoleApplication8.EASLoginProxyService service = new ConsoleApplication8.EASLoginProxyService();
WSContext context = service.login("user", "password", "eas", "A001", "L2", 2, string.Empty);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章