我正在尝试通过使用多个端点的SOAP连接到应用程序。
通过Cookie进行身份验证。因此,我希望绑定上的AllowCookies
选项为将来的调用设置cookie。这似乎从未奏效。
public MyService(IPreferences preferences)
{
// Create binding for end-point 1
_binding = new BasicHttpBinding {AllowCookies = true};
_remoteAddress = new EndpointAddress("http://web.server.com/end-point-1");
ChannelFactory<LoginService> factory = new ChannelFactory<LoginService>(_binding, _remoteAddress);
_loginService = factory.CreateChannel();
// Use the same binding as for the first channel
_remoteAddress = new EndpointAddress("http://web.server.com/end-point-2");
ChannelFactory<DataSerivce> factory2 = new ChannelFactory<DataSerivce>(_binding, _remoteAddress);
_dataSerivce = factory2.CreateChannel();
_preferences = preferences;
Login();
}
// Login & test if data fetch is possible
public async Task Login()
{
loginRequest input = new loginRequest
{
LoginInput = new LoginInput
{
username = _preferences.Username,
password = _preferences.Password,
group = "group1"
}
};
await _loginService.loginAsync(input);
exportDataRequest exportDataRequest = new exportDataRequest
{
ExportDataInput = new ExportDataInput
{
xmlFileName = "export.xml",
exportObjects = new[] {new ModelObject {uid = "BiLAAASe43wGrD"}}}
};
// this throws an exception for not being logged in
await _dataSerivce.exportDataAsync(exportDataRequest);
}
我正在寻找某种方式来手动获取cookie并将其移至其他服务。