4. SRU
Prev | Chapter 6. SOAP and SRU | Next

## 4. SRU

SRU SOAP is just one implementation of a SOAP handler as described in the previous section. The encoder/decoder handler for SRU is defined as follows:

    #include <yaz/srw.h>

    int yaz_srw_codec(ODR o, void * pptr,
                      Z_SRW_GDU **handler_data,
                      void *client_data, const char *ns);

Here, `Z_SRW_GDU` is either searchRetrieveRequest or a searchRetrieveResponse.

### Note

The xQuery and xSortKeys are not handled yet by the SRW implementation of YAZ. Explain is also missing. Future versions of YAZ will include these features.

The definition of searchRetrieveRequest is:

    typedef struct {

    #define Z_SRW_query_type_cql  1
    #define Z_SRW_query_type_xcql 2
    #define Z_SRW_query_type_pqf  3
        int query_type;
        union {
            char *cql;
            char *xcql;
            char *pqf;
        } query;

    #define Z_SRW_sort_type_none 1
    #define Z_SRW_sort_type_sort 2
    #define Z_SRW_sort_type_xSort 3
        int sort_type;
        union {
            char *none;
            char *sortKeys;
            char *xSortKeys;
        } sort;
        int  *startRecord;
        int  *maximumRecords;
        char *recordSchema;
        char *recordPacking;
        char *database;
    } Z_SRW_searchRetrieveRequest;

Please observe that data of type xsd:string is represented as a char pointer (`char *`). A null pointer means that the element is absent. Data of type xsd:integer is represented as a pointer to an int (`int *`). Again, a null pointer is used for absent elements.

The SearchRetrieveResponse has the following definition.

    typedef struct {
        int * numberOfRecords;
        char * resultSetId;
        int * resultSetIdleTime;

        Z_SRW_record *records;
        int num_records;

        Z_SRW_diagnostic *diagnostics;
        int num_diagnostics;
        int *nextRecordPosition;
    } Z_SRW_searchRetrieveResponse;

The `num_records` and `num_diagnostics` is number of returned records and diagnostics respectively, and also correspond to the "size of" arrays `records` and `diagnostics`.

A retrieval record is defined as follows:

    typedef struct {
        char *recordSchema;
        char *recordData_buf;
        int recordData_len;
        int *recordPosition;
    } Z_SRW_record;

The record data is defined as a buffer of some length so that data can be of any type. SRW 1.0 currently doesn't allow for this (only XML), but future versions might do.

And, a diagnostic as:

    typedef struct {
        int  *code;
        char *details;
    } Z_SRW_diagnostic;

Prev | Up | Next
3. SOAP Packages | Home | Chapter 7. Supporting Tools