// // Licensed Materials - Property of IBM - You may copy, modify, and distribute // these samples, or their modifications, in any form, internally or as part of your // application or related documentation. // // These samples have not been tested under all conditions and are provided to you // by IBM without obligation of support of any kind. // // IBM PROVIDES THESE SAMPLES "AS IS", SUBJECT TO ANY STATUTORY WARRANTIES // THAT CANNOT BE EXCLUDED. IBM MAKES NO WARRANTIES OR CONDITIONS, EITHER // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND // NON-INFRINGEMENT REGARDING THESE SAMPLES OR TECHNICAL SUPPORT, IF ANY. // // (c) Copyright IBM Corporation 2014. All Rights Reserved. // // U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted // by GSA ADP Schedule Contract with IBM Corp. // /* For a given artifact URL this will return the resource representation. It is a pre-requisite that have configured the OSLC integration point in Remote Services. */ // prevent dxl timeout dialog pragma runLim, 0 // dialogs DB dlgMain // ui controls DBE fldResourceURL DBE txtRequest DBE txtResponse HttpHeader fnCreateRequestHeader() { HttpHeader header = create HttpHeaderEntry entry Buffer buff = create // this is the key/value pair representing accept type add(header, "Accept", "text/xml") // this is the key/value pair representing oslc version add(header, "OSLC-Core-Version", "2.0") // this is the key/value pair representing content type add(header, "Content-Type", "application/rdf+xml") // the following demonstrates the use of the header iterator for entry in header do { buff += entry.key buff += ":" buff += entry.value buff += "\n" } // display the request set(txtRequest, stringOf(buff)) // remember to delete the buffer delete buff return header } void fnPerformGET(DB xx) { string resourceURL = get fldResourceURL if (!isVoid_(resourceURL)) { set(txtRequest, "") set(txtResponse, "") // create the header HttpHeader reqHeader = fnCreateRequestHeader() // no body is necessary HttpBody reqBody = null // send request HttpResponse resp = HttpRequest(HttpGet, resourceURL, reqBody, reqHeader) if (resp != null) { HttpHeaderEntry entry Buffer buff = create buff += "*** STATUS ***\n" buff += resp.code "\n" buff += "*** HEADER ***\n" // another example of the header iterator for entry in resp.header do { buff += entry.key buff += ":" buff += entry.value buff += "\n" } buff += "*** BODY ***\n" HttpBody respBody = resp.body if (respBody != null) { buff += stringOf(respBody.value) "" } else { buff += "No body was returned." } // display the response set(txtResponse, stringOf(buff)) // remember to delete the buffer delete buff // remember to delete the response delete resp } else { // warn user errorBox(dlgMain, "No response was returned.") } // remember to delete the request delete reqHeader delete reqBody } else { // just ignore it } } void fnShowUI() { // dialog dlgMain = create(dbExplorer, "Sample DXL For OSLC GET", styleCentred | styleThemed) // field fldResourceURL = field(dlgMain, "Resource URL:", "", 100, false) // text txtRequest = text(dlgMain, "Request", "", 100, true) // text txtResponse = text(dlgMain, "Response", "", 200, true) apply(dlgMain, "GET", fnPerformGET) show dlgMain } fnShowUI()