GetServiceBinding
Retrieves source or metadata of an ABAP service binding by name using the ADT Business Services endpoint. Supports XML, JSON, or plain text output.
Instructions
Retrieve ABAP service binding source/metadata by name via ADT Business Services endpoint.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service_binding_name | Yes | Service binding name (for example: ZUI_MY_BINDING). Case-insensitive. | |
| response_format | No | Preferred response format. "json" requests JSON from endpoint, "xml" parses XML payload, "plain" returns raw text. | xml |
Implementation Reference
- The main handler function `handleGetServiceBinding` that retrieves an ABAP service binding by name via ADT Business Services endpoint. It validates input, calls `client.getServiceBinding().read()`, and returns the parsed response.
export async function handleGetServiceBinding( context: HandlerContext, args: GetServiceBindingArgs, ) { const { connection, logger } = context; try { if (!args?.service_binding_name) { throw new Error('service_binding_name is required'); } const serviceBindingName = args.service_binding_name.trim().toUpperCase(); const responseFormat = args.response_format ?? 'xml'; const client = createAdtClient(connection, logger); const state = await client.getServiceBinding().read({ bindingName: serviceBindingName, }); const response = state?.readResult; if (!response) { throw new Error( `Read did not return a response for service binding ${serviceBindingName}`, ); } return return_response({ data: JSON.stringify( { success: true, service_binding_name: serviceBindingName, response_format: responseFormat, status: response.status, payload: parseServiceBindingPayload(response.data, responseFormat), }, null, 2, ), status: response.status, statusText: response.statusText, headers: response.headers, config: response.config, }); } catch (error: unknown) { logger?.error('Error reading service binding:', error); return return_error(error); } } - The `TOOL_DEFINITION` constant which defines the tool's name ('GetServiceBinding'), availability, description, and input schema (service_binding_name required, response_format optional with enum of xml/json/plain).
export const TOOL_DEFINITION = { name: 'GetServiceBinding', available_in: ['onprem', 'cloud'] as const, description: 'Retrieve ABAP service binding source/metadata by name via ADT Business Services endpoint.', inputSchema: { type: 'object', properties: { service_binding_name: { type: 'string', description: 'Service binding name (for example: ZUI_MY_BINDING). Case-insensitive.', }, response_format: { type: 'string', enum: ['xml', 'json', 'plain'], description: 'Preferred response format. "json" requests JSON from endpoint, "xml" parses XML payload, "plain" returns raw text.', default: 'xml', }, }, required: ['service_binding_name'], }, } as const; - The `parseServiceBindingPayload` helper function used by the handler to parse the response payload into XML, JSON, or plain text based on the requested format.
export function parseServiceBindingPayload( payload: unknown, format: ServiceBindingResponseFormat, ): unknown { if (format === 'plain') { return payload; } if (format === 'json') { if (typeof payload === 'string') { try { return JSON.parse(payload); } catch { return payload; } } return payload; } if (typeof payload !== 'string') { return payload; } const trimmed = payload.trim(); if (!trimmed.startsWith('<')) { return payload; } try { const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '', }); return parser.parse(trimmed); } catch { return payload; } } - src/lib/handlers/groups/HighLevelHandlersGroup.ts:745-747 (registration)Registration of the GetServiceBinding tool in the HighLevelHandlersGroup, mapping `GetServiceBinding_Tool` definition to the `handleGetServiceBinding` handler with context.
{ toolDefinition: GetServiceBinding_Tool, handler: withContext(handleGetServiceBinding), - src/handlers/compact/high/compactRouter.ts:146-150 (registration)Compact router registration mapping the SERVICE_BINDING 'get' route to `handleGetServiceBinding` as a CompactHandler.
SERVICE_BINDING: { create: handleCreateServiceBinding as unknown as CompactHandler, get: handleGetServiceBinding as unknown as CompactHandler, update: handleUpdateServiceBinding as unknown as CompactHandler, delete: handleDeleteServiceBinding as unknown as CompactHandler,