Listing 5: Implementing the web-service interface.

[
    request_handler(name="Default", sdl="GenUltraMaxWSDL"),
    soap_handler(
        name="UltraMaxService", 
        namespace="urn:UltraMaxService",
        protocol="soap"
    )
]
 class CUltraMaxService : public IUltraMaxService
{
public:
    CComPtr<ISessionStateService> m_spSessionSvc;
    CComPtr<ISession> m_spSession;
    // UltraMax COM pointer
    UltraMax::IUltraMaxPtr m_pUltraMax;
    // SOAP Header
    MyHeader m_Header;
    HTTP_CODE InitializeHandler(AtlServerRequest *pRequestInfo,
          IServiceProvider *pProvider)
    {
        if ( CSoapHandler<CUltraMaxService>::InitializeHandler(
                pRequestInfo, pProvider) != HTTP_SUCCESS )
            return HTTP_FAIL;
        // Get the ISessionStateService from the ISAPI extension
        if ( FAILED(pProvider->QueryService(
                 __uuidof(ISessionStateService), &m_spSessionSvc)) )
            return HTTP_FAIL;
        return HTTP_SUCCESS;
    }
    // Web Methods
    [ soap_method, soap_header("m_Header",required=false,in=false,out=true) ]
    HRESULT LogOn(BSTR LoginID, BSTR Password);
    [ soap_method, soap_header("m_Header") ]
    HRESULT GetSongs(LONG* Size, SongInfo** Songs);
    [ soap_method, soap_header("m_Header") ]
    HRESULT SetSongs(LONG Size, SongInfo* Songs);
    [ soap_method, soap_header("m_Header") ]
    HRESULT GetReleaseDate(BSTR* CurrentDate);
private:
    BSTR    m_ErrorDesc;
    HRESULT EnsureSession();
    HRESULT Prolog();
    HRESULT Epilog(HRESULT hr);
    virtual HRESULT GenerateAppError(IWriteStream *pStream, HRESULT hr);
};