[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-05 UTC。"],[[["\u003cp\u003eThis documentation covers API proxies within Apigee and Apigee hybrid, which are managed facades for backend services, consisting of a ProxyEndpoint and a TargetEndpoint.\u003c/p\u003e\n"],["\u003cp\u003eWhile technically possible, using service callouts to invoke a backend service in an API proxy without a defined target endpoint results in the loss of analytics data regarding the performance of the external service.\u003c/p\u003e\n"],["\u003cp\u003eAn API proxy can be configured with a "null route" to create a "no target" proxy that does not invoke a backend service, but this configuration should not include service callouts.\u003c/p\u003e\n"],["\u003cp\u003eBest practice dictates that if an API proxy interacts with a single external service, it should define that service as the target endpoint, rather than relying on a no-target configuration with service callouts.\u003c/p\u003e\n"],["\u003cp\u003eService callouts are intended to support mashup scenarios, not to replace target endpoint invocation, as such, invoking a service callout in a no-target proxy should be avoided.\u003c/p\u003e\n"]]],[],null,["# Antipattern: Use Service Callout Policy to invoke a backend service in a No Target API Proxy\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/antipatterns/service-callout-no-target) documentation.*\n\n\nAn API proxy is a managed facade for backend services. A basic API proxy configuration consists of a\n[ProxyEndpoint](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies)\n(defining the URL of the API proxy) and a\n[TargetEndpoint](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies)\n(defining the URL of the backend service).\n\n\nApigee offers a lot of flexibility for building sophisticated behavior on top of this pattern.\nFor example, you can add policies to control the way the API processes a client request before sending\nit to the backend service, or manipulate the response received from the backend service before\nforwarding it to the client. You can invoke other services using\n[service callout policies](/apigee/docs/api-platform/reference/policies/service-callout-policy),\nadd custom behavior by adding [Javascript code](/apigee/docs/api-platform/reference/policies/javascript-policy),\nand even create an API proxy that doesn't invoke a backend service.\n\nAntipattern\n-----------\n\n\nUsing service callouts to invoke a backend service in an API proxy with no routes to a target endpoint\nis technically feasible, but results in the loss of analytics data about the performance of the\nexternal service.\n\n\nAn API proxy that does not contain target routes can be useful in cases where you do not need to forward\nthe request message to the TargetEndpoint. Instead, the ProxyEndpoint performs all necessary\nprocessing. For example, the ProxyEndpoint could retrieve data from a lookup to the API service's\nkey/value store and return the response without invoking a backend service.\n\n\nYou can define a [null Route](/apigee/docs/api-platform/reference/api-proxy-configuration-reference#proxyendpoint-nullroutes)\nin an API proxy, as shown here: \n\n```text\n\u003cRouteRule name=\"noroute\"/\u003e\n```\n\n\nA proxy using a null route is a \"no target\" proxy, because it does not invoke a target backend service.\n\n\nIt is technically possible to add a service callout to a no target proxy to invoke an external service, as shown in the example below: \n\n```world-of-warcraft-toc\n\u003c!-- /antipatterns/examples/service-callout-no-target-1.xml --\u003e\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cDescription/\u003e\n \u003cFaultRules/\u003e\n \u003cPreFlow name=\"PreFlow\"\u003e\n \u003cRequest\u003e\n \u003cStep\u003e\n \u003cName\u003eServiceCallout-InvokeBackend\u003c/Name\u003e\n \u003c/Step\u003e\n \u003c/Request\u003e\n \u003cResponse/\u003e\n \u003c/PreFlow\u003e\n \u003cPostFlow name=\"PostFlow\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PostFlow\u003e\n \u003cFlows/\u003e\n \u003cHTTPProxyConnection\u003e\n \u003cBasePath\u003e/no-target-proxy\u003c/BasePath\u003e\n \u003cProperties/\u003e\n \u003cVirtualHost\u003esecure\u003c/VirtualHost\u003e\n \u003c/HTTPProxyConnection\u003e\n \u003cRouteRule name=\"noroute\"/\u003e\n\u003c/ProxyEndpoint\u003e\n```\n\n\nHowever, the proxy cannot provide analytics information about the external service behavior (such as processing time or error rates), making it difficult to assess the performance of the external service.\n\nImpact\n------\n\n- Analytics information on the interaction with the external service ( error codes, response time, target performance, etc.) is unavailable\n- Any specific logic required before or after invoking the service callout is included as part of the overall proxy logic, making it harder to understand and reuse.\n\nBest Practice\n-------------\n\n\nIf an API proxy interacts with only a single external service, the proxy should follow the basic\ndesign pattern, where the backend service is defined as the target endpoint of the API proxy. A proxy\nwith no routing rules to a target endpoint should not invoke a backend service using the ServiceCallout policy.\n\n\nThe following proxy configuration implements the same behavior as the example above, but follows best\npractices: \n\n```carbon\n\u003c!-- /antipatterns/examples/service-callout-no-target-2.xml --\u003e\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cDescription/\u003e\n \u003cFaultRules/\u003e\n \u003cPreFlow name=\"PreFlow\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PreFlow\u003e\n \u003cPostFlow name=\"PostFlow\"\u003e\n \u003cRequest/\u003e\n \u003cResponse/\u003e\n \u003c/PostFlow\u003e\n \u003cFlows/\u003e\n \u003cHTTPProxyConnection\u003e\n \u003cBasePath\u003e/simple-proxy-with-route-to-backend\u003c/BasePath\u003e\n \u003cProperties/\u003e\n \u003cVirtualHost\u003esecure\u003c/VirtualHost\u003e\n \u003c/HTTPProxyConnection\u003e\n \u003cRouteRule name=\"default\"\u003e\n \u003cTargetEndpoint\u003edefault\u003c/TargetEndpoint\u003e\n \u003c/RouteRule\u003e\n\u003c/ProxyEndpoint\u003e\n```\n\n\nUse Service callouts to support mashup scenarios, where you want to invoke external services before\nor after invoking the target endpoint. Service callouts are not meant to replace target endpoint\ninvocation.\n\nFurther reading\n---------------\n\n- [Understanding APIs and API proxies](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies)\n- [How to configure Route Rules](/apigee/docs/api-platform/reference/api-proxy-configuration-reference#proxyendpoint-howtoconfigurerouterules)\n- [Null Routes](/apigee/docs/api-platform/reference/api-proxy-configuration-reference#proxyendpoint-nullroutes)\n- [Service Callout policy](/apigee/docs/api-platform/reference/policies/service-callout-policy)"]]