- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Unable to create EwsClient instance
I tried to create EwsClient with the following two ways and got the same exception: "The HTTP request is unauthorized with client authentication scheme 'Digest'. The authentication header received from the server was 'Digest realm="ews@SxWBM",qop="auth",nonce="827DD2915ED2AF6BC10A82600FE90014",opaque="6CA079"'."
EwsClientAddress = http://localhost:8081/EcoStruxure/DataExchange;
1.
var client = MongooseObjectFactory.Current.GetInstance<IManagedEwsClient>();
var endpoint = new EwsConnection
{
EwsEndpoint = EwsClientAddress,
UserName = SBOConnectionSetting.UserName,
Password = SBOConnectionSetting.Password
};
var resp = client.GetWebServiceInformation(endpoint);
2.
EwsServerDataAdapter.ConnectExisting(EwsServer.Name, EwsServer.UserName, EwsServer.Password);
EwsSecurity ClientSecurity = new EwsSecurity
{
UserName = SBOConnectionSetting.UserName,
Password = SBOConnectionSetting.Password
};
var clientObj = new EwsClient(ClientSecurity, EwsClientAddress);
It seems that in SmartConnector V2.2.108, the AuthenticationScheme in EwsSecurity is removed.
What should I do to prevent this exception happening?
Thanks!
Juh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Hi,
I have found out the problem. The wrong password caused the exception.
Thanks!
Juh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Juh,
I know you discovered the issue on your own, but I wanted to add a couple of comments.
- AuthenticationScheme was removed as it is no longer appropriate to change the EWS authentication to anything other than HTTP Digest.
- Besides supplying incorrect credentials, the error message you reported may also be symptomatic of a condition when SBO has exhausted it's available client connections. This occurs when client code makes a connection and disposes of it frequently. To alleviate this, SmartConnector 2.2, introduced a IManagedEwsClient which can be used without the need to instantiate the EwsClient class. Rather, you call object factory to get an instance of the managed client. See code snippet below.
var creds = new EwsConnection
{
EwsEndpoint = ServerAddress,
UserName = user.UserName,
Password = password
};
var client = MongooseObjectFactory.Current.GetInstance<IManagedEwsClient>();
client.GetWebServiceInformation(creds);
Whether you use EwsClient or IManagedEwsClient is largely one of personal preference however if you frequently instantiate and dispose of your connection, the IManagedEwsClient would be the preferred approach
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Thank you, Mark.

