如何在基于 Acumatica 屏幕的 API 和基于合同的 API 之间共享登录会话?
1 回答
3
从 5.30.1672 开始支持在基于合同和基于屏幕的 API 之间共享会话数据。
在下面的代码片段中,我们通过基于合同的 API 登录,检索会话 cookie 并在基于屏幕的 API 中使用它。
string sharedCookie;
var soapClient = new DefaultSoapClient();
using (new OperationContextScope(soapClient.InnerChannel))
{
soapClient.Login("admin", "123", null, null, null);
var responseMessageProperty = (HttpResponseMessageProperty)
OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
}
try
{
apitest.Screen context = new apitest.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaCBWS/Soap/APITEST.asmx";
context.CookieContainer.SetCookies(new Uri(context.Url), sharedCookie);
SO301000Content salesOrdersSchema = context.SO301000GetSchema();
var commands = new Command[]
{
new Value
{
LinkedCommand = salesOrdersSchema.OrderSummary.OrderType,
Value = "SO"
},
salesOrdersSchema.OrderSummary.ServiceCommands.EveryOrderNbr,
salesOrdersSchema.OrderSummary.OrderType,
salesOrdersSchema.OrderSummary.OrderNbr,
salesOrdersSchema.OrderSummary.Description
};
var orders = context.SO301000Export(commands, null, 10, false, false);
}
finally
{
soapClient.Logout();
}
}
于 2016-05-19T21:50:54.290 回答