IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Referential integrity X-Tension

  • 1.  Referential integrity X-Tension

    Posted Mon September 12, 2005 04:29 PM

    Hi everybody!

    I need to build some kind of Referential Integrity X-Tension.

    I have a “Companies” schema and another schema called “Cities”. When i execute a “Company” insertion in Tamino, i have to check the “City” code for a valid value. If the “City” code doesn’t exist in the “Cities” schema, i can’t execute the insertion, i need to send an error message.

    Any example for this kind of X-Tension?

    Thanks in advance,

    Malena


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: Referential integrity X-Tension

    Posted Tue September 13, 2005 09:21 AM

    Hi Malena,

    what you need is an onInsert trigger in your schema at the node containing the city(-code).

    You also need a server extension with an onInsert trigger function like

    
    public void checkCode (String collection, String doctype, String ino_id, String XMLObject)
    {
    
    // get the content of the Code element
    int IDREFStartPos = XMLObject.indexOf (">") + 1;
    String IDREF = XMLObject.substring (IDREFStartPos, XMLObject.indexOf ('<', IDREFStartPos));
    
    // checks if a document of type City in collection CitiesCollection with attribute Code = IDREF exists
    StringBuffer Response = new StringBuffer();
    StringBuffer  XMLMessage = new StringBuffer();
    
    int ret =  SxsXMLXql ("CitiesCollection",  "City[@Code='" + IDREF + "']", Response);
    
    if (ret !=  0) {
    SxsXMLGetMessage(XMLMessage);
    SxsException (ret, XMLMessage.toString());
    } 
    else if (Response.length() == 0) {
    SxsXMLGetMessage(XMLMessage);
    SxsException (-1, ": " + XMLMessage.toString()+ ": no City document found.");
    } 
    }

    This doesn’t look too difficult.

    Best regards,
    Julius Geppert


    #webMethods
    #Tamino
    #API-Management