Sap B1 服务层写入(POST、PATCH 等)错误。 Asp.Net HttpWeb 请求
Sap B1 Service Layer Write (POST, PATCH etc.) Error. Asp.Net Httpwebrequest
当我通过 Asp.Net HttpWebRequest 向 Sap B1 服务层发送数据时遇到异常。
我们正在使用
https://xx.xx.x.xxx:50000/b1s/v1/ 服务层操作的地址
但后来我们切换到
http://xx.xx.x.xxx:50001/b1s/v1/ 地址(负载均衡端口)。
这解决了一些问题,但现在我们面临着
"The underlying connection was closed: The connection was closed unexpectedly." 错误。该错误仅发生在 "POST" 和 "PATCH" 等写入方法中。有趣的是,在前 2 到 3 次请求后很少发生错误。
我发送了如下所示的 HttpWebRequest 请求,我从 Sap B1 示例项目复制了此设置,还尝试了许多不同的设置,但无法解决问题。谢谢。
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PATCH"
request.Accept = "application/json;odata=minimalmetadata";
request.KeepAlive = true;
request.ServicePoint.Expect100Continue = false;
request.AllowAutoRedirect = true;
request.ContentType = "application/json;odata=minimalmetadata;charset=utf8";
request.Timeout = 10000000;
request.Headers.Add(HttpRequestHeader.Cookie, "B1SESSION=" + GetSessionId());
我的 Global.asax.cs
中也有以下设置
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback +=
(sndr, cert, chain, sslPolicyErrors) => true;
我们发现"The underlying connection was closed: The connection was closed unexpectedly."错误的主要原因是硬件资源不足。在我们切换到更强大的服务器后,该服务器使用与旧机器(开发环境)相同的服务层配置,问题就解决了。
当我通过 Asp.Net HttpWebRequest 向 Sap B1 服务层发送数据时遇到异常。
我们正在使用 https://xx.xx.x.xxx:50000/b1s/v1/ 服务层操作的地址 但后来我们切换到 http://xx.xx.x.xxx:50001/b1s/v1/ 地址(负载均衡端口)。 这解决了一些问题,但现在我们面临着 "The underlying connection was closed: The connection was closed unexpectedly." 错误。该错误仅发生在 "POST" 和 "PATCH" 等写入方法中。有趣的是,在前 2 到 3 次请求后很少发生错误。
我发送了如下所示的 HttpWebRequest 请求,我从 Sap B1 示例项目复制了此设置,还尝试了许多不同的设置,但无法解决问题。谢谢。
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PATCH"
request.Accept = "application/json;odata=minimalmetadata";
request.KeepAlive = true;
request.ServicePoint.Expect100Continue = false;
request.AllowAutoRedirect = true;
request.ContentType = "application/json;odata=minimalmetadata;charset=utf8";
request.Timeout = 10000000;
request.Headers.Add(HttpRequestHeader.Cookie, "B1SESSION=" + GetSessionId());
我的 Global.asax.cs
中也有以下设置 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback +=
(sndr, cert, chain, sslPolicyErrors) => true;
我们发现"The underlying connection was closed: The connection was closed unexpectedly."错误的主要原因是硬件资源不足。在我们切换到更强大的服务器后,该服务器使用与旧机器(开发环境)相同的服务层配置,问题就解决了。