Archived:Implementing Automatic Web Service Authentication using Symbian C++
Article Metadata
Tested with
Compatibility
Article
Overview
A web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically Web Services Description Language (WSDL)).
The S60 Web Services Framework (WSF) API abstracts the details of connecting to and communicating with a Web service. It also provides helper classes for sending requests and handling the responses of Web services.
Description
A Web Services Consumer (WSC) application can directly connect to a basic Web Service if it does not involve any authentication. However, if authentication is enabled, an authentication dialog is popped whenever the consumer application tries to establish a connection. The authentication dialog can be avoided by using the following code snippet before starting the connection.
Solution
Header Files: Senservicemanager.h, Senidentityprovider.h
Library: SenServMgr.lib, SenServDesc.lib
Required Capabilities: ReadUserData, WriteUserData, NetworkServices
Code:
// Creating an instance of CSenServiceManager
CSenServiceManager* pManager = CSenServiceManager::NewLC();<br>
// Creating an instance of IdP and registering it. Notice, that endpoint is the<br>// endpoint to the actual Web Service Provider.
CSenIdentityProvider* pIdp = CSenIdentityProvider::NewLC(KWSPEndPoint());<br>
// Set BASIC-AUTH credentials
pIdp->SetUserInfo(KUser, KUser, KPass);<br>
// Set FrameworkID (constant declared in SenServiceConnection.h)
pIdp->SetFrameworkID(KDefaultBasicWebServicesFrameworkID);<br>
TInt error = pManager->RegisterIdentityProviderL(*pIdp);
CleanupStack::PopAndDestroy(2); // pManager, pIdp

