예제 #1
0
        /// <summary>
        /// 路由查询接口
        /// <para>
        /// 详细说明请查看丰桥API说明<seealso cref="https://qiao.sf-express.com/pages/developDoc/index.html?level2=314896"/>
        /// </para>
        /// </summary>
        /// <param name="expressRoute"></param>
        /// <param name="saveRequestXmlAction">落地请求报文的委托</param>
        /// <param name="saveResponseXmlAction">落地响应报文的委托</param>
        /// <returns></returns>
        public async Task <IEnumerable <ExpressRouteGroup> > RouteAsync(ExpressRoute expressRoute, Action <string> saveRequestXmlAction = null, Action <string> saveResponseXmlAction = null)
        {
            var    request    = new Request <RouteRequestBody>(new RouteRequestBody(expressRoute), options.ClientCode);
            string xmlContent = request.ToXml();

            saveRequestXmlAction?.Invoke(xmlContent);
            var responseStr = await httpClient.PostAsync(xmlContent, BuidVerifyCode(xmlContent));

            saveResponseXmlAction?.Invoke(responseStr);
            if (responseStr.IsNullOrWhiteSpace())
            {
                return(null);
            }
            Response <RouteResponseBody> routeResponse = new Response <RouteResponseBody>()
            {
                Body = new RouteResponseBody()
            };

            routeResponse.Fill(responseStr.ToXmlDocument());
            if (routeResponse.Error != null)
            {
                throw SFExpressException.ThrowException(routeResponse.Error);
            }
            return(routeResponse.Body.Result);
        }
예제 #2
0
 public RouteRequestBody(ExpressRoute expressRoute)
 {
     Data = expressRoute;
 }