Skip to content

Commit 0982817

Browse files
Separate approaches
1 parent b7729d2 commit 0982817

File tree

3 files changed

+132
-58
lines changed

3 files changed

+132
-58
lines changed

docs-java/environments/kyma.mdx

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,20 @@ Apply the YAML with `kubectl apply -n` into the namespace of your application po
659659

660660
### Executing Requests
661661

662-
In your application you can now configure a destination to execute requests:
662+
The SAP Cloud SDK offers two distinct approaches for executing requests through the Transparent Proxy in Kyma. Choose the approach that best fits your application's architecture and requirements.
663+
664+
## Approach 1: TransparentProxyDestination Builder (Recommended)
665+
666+
The **TransparentProxyDestination Builder** approach provides explicit, fine-grained control over individual destination configurations. This is the recommended approach for most use cases as it offers maximum flexibility and clear configuration management.
667+
668+
### When to Use This Approach
669+
670+
- You need specific control over individual destination configurations
671+
- You want to set custom headers or properties per destination
672+
- You prefer explicit destination management
673+
- You need different configurations for different destinations
674+
675+
### Implementation Examples
663676

664677
<Tabs
665678
groupId="dynamic-dest"
@@ -670,6 +683,10 @@ In your application you can now configure a destination to execute requests:
670683
]}>
671684
<TabItem value="single">
672685

686+
**For Concrete SAP Destinations:**
687+
688+
Use this when connecting to a specific, pre-configured destination with a dedicated Destination Custom Resource.
689+
673690
```java
674691
TransparentProxyDestination destination = TransparentProxyDestination
675692
.destination(<destination-custom-resource-name>.<destination-custom-resource-namespace>)
@@ -684,6 +701,10 @@ List<SalesArea> execute = new DefaultSalesAreaService().getAllSalesArea() // exa
684701
</TabItem>
685702
<TabItem value="gateway">
686703

704+
**For Dynamic Destination Gateway:**
705+
706+
Use this when you need to connect to arbitrary destinations dynamically using a Gateway Destination Custom Resource.
707+
687708
```java
688709
TransparentProxyDestination destination = TransparentProxyDestination
689710
.gateway("my-destination", <destination-custom-resource-name>.<destination-custom-resource-namespace>)
@@ -701,11 +722,53 @@ List<SalesArea> execute = new DefaultSalesAreaService().getAllSalesArea() // exa
701722
`<destination-custom-resource-namespace>` can be omitted if the destination custom resource is created in the same namespace as the application workload.
702723
:::
703724

704-
The code above shows an example how you can then use the `destination` object to perform an OData request against the system.
725+
## Approach 2: Transparent Proxy Loader
726+
727+
The **Transparent Proxy Loader** approach provides centralized proxy configuration where **all destination requests** are automatically routed through a single registered gateway without requiring explicit destination builders.
728+
729+
### When to Use This Approach
730+
731+
- You want all destinations to automatically route through a single transparent proxy gateway
732+
- You prefer a centralized, "set-it-and-forget-it" configuration approach
733+
- You have many destinations that should all use the same proxy configuration
734+
- You want to minimize code changes when migrating from traditional destination access
735+
736+
### Implementation Examples
737+
738+
**Step 1: Register the Transparent Proxy (typically during application startup):**
739+
740+
```java
741+
// Register with default port 80
742+
TransparentProxy.register("<destination-gateway-host>");
743+
744+
// OR register with custom port
745+
TransparentProxy.register("http://<destination-gateway-host>", 8080);
746+
```
747+
748+
**Step 2: Use destinations normally - they will automatically route through the registered proxy:**
749+
750+
```java
751+
// All subsequent destination requests will be routed through the registered gateway
752+
// No explicit TransparentProxyDestination creation needed
753+
Destination destination = DestinationAccessor.getDestination("my-destination");
754+
755+
List<SalesArea> execute = new DefaultSalesAreaService().getAllSalesArea() // example OData request
756+
.execute(destination);
757+
```
758+
759+
## Choosing Between the Two Approaches
760+
761+
| Aspect | TransparentProxyDestination Builder | Transparent Proxy Loader |
762+
| ---------------------------- | -------------------------------------------- | ---------------------------------------- |
763+
| **Control Level** | Fine-grained, per-destination control | Centralized, all-destinations control |
764+
| **Configuration Complexity** | Higher - explicit per destination | Lower - one-time registration |
765+
| **Flexibility** | High - different configs per destination | Lower - same config for all destinations |
766+
| **Migration Effort** | Medium - explicit destination changes needed | Low - minimal code changes |
767+
| **Use Case** | Varied destination requirements | Uniform destination handling |
768+
| **Recommended For** | Most applications, complex scenarios | Simple proxy setups, migration scenarios |
705769

706770
:::tip Connecting to Cloud systems
707-
The above approach is not limited to destinations of proxy type `ON_PREMISE`.
708-
`INTERNET` destinations are equally supported.
771+
Both approaches support destinations of any proxy type including `ON_PREMISE` and `INTERNET` destinations.
709772
:::
710773

711774
### Troubleshooting

docs-java/features/connectivity/008-transparent-proxy.mdx

Lines changed: 65 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ It uses this destination to forward the request to the target system or to the C
5353
Consequently, your app does not interact with SAP Destination service or Connectivity service.
5454
This means your application do not require bindings to these two services, everything is handled by the Transparent Proxy.
5555

56-
## Creating Transparent Proxy Destinations
56+
## Approach 1: TransparentProxyDestination Builder
5757

58-
The `TransparentProxyDestination` class provides two types of builders for different use cases:
58+
The `TransparentProxyDestination` class provides explicit destination builders for direct control over transparent proxy connections.
59+
This approach gives you fine-grained control over individual destination configurations and is recommended for most use cases.
5960

60-
### 1. Destination
61+
### Creating Destinations
62+
63+
#### Concrete SAP Destination
6164

6265
Allows you to connect to a concrete SAP destination.
6366
Setting generic headers is allowed but dynamic properties like destination name or fragments is not.
@@ -76,7 +79,7 @@ TransparentProxyDestination destination = TransparentProxyDestination
7679
`<destination-custom-resource-namespace>` can be omitted if the destination custom resource is created in the same namespace as the application workload.
7780
:::
7881

79-
### 2. Gateway
82+
#### Dynamic Destination Gateway
8083

8184
Allows you to connect to arbitrary SAP destinations you have access to.
8285
As a prerequisite, you have to create a Gateway Destination Custom Resource inside the Kubernetes cluster.
@@ -89,25 +92,26 @@ TransparentProxyDestination destination = TransparentProxyDestination
8992
.build();
9093
```
9194

92-
## Tenant Configuration
95+
### Configuration Options
96+
97+
#### Tenant Configuration
9398

9499
The SAP Cloud SDK automatically sets the current tenant as tenant ID on a **per-request** basis.
95100

96101
In case a fixed tenant should be used, you can manually set it as follows:
97102

98-
### Destination
103+
**For Concrete Destinations:**
99104

105+
```java
100106
// Using a fixed tenant ID (automatically set by SAP Cloud SDK if not specified)
101107
// alternatively, .tenantSubdomain("..") can be used, but only one of the two options may be set
102-
103-
```java
104108
TransparentProxyDestination destination = TransparentProxyDestination
105109
.destination(<destination-custom-resource-name>.<destination-custom-resource-namespace>)
106110
.tenantId("my-tenant-id")
107111
.build();
108112
```
109113

110-
### Gateway
114+
**For Gateway Destinations:**
111115

112116
```java
113117
// Using a fixed tenant ID (automatically set by SAP Cloud SDK if not specified)
@@ -118,13 +122,13 @@ TransparentProxyDestination destination = TransparentProxyDestination
118122
.build();
119123
```
120124

121-
## Authorization Header Configuration
125+
#### Authorization Header Configuration
122126

123127
The SAP Cloud SDK automatically sets the current user's authorization token in the `Authorization` header on a **per-request** basis.
124128

125129
In case a fixed authorization token should be used, you can manually set it as follows:
126130

127-
### Destination
131+
**For Concrete Destinations:**
128132

129133
```java
130134
TransparentProxyDestination destination = TransparentProxyDestination
@@ -133,7 +137,7 @@ TransparentProxyDestination destination = TransparentProxyDestination
133137
.build();
134138
```
135139

136-
### Gateway
140+
**For Gateway Destinations:**
137141

138142
```java
139143
TransparentProxyDestination destination = TransparentProxyDestination
@@ -144,18 +148,18 @@ TransparentProxyDestination destination = TransparentProxyDestination
144148

145149
**Note**: When you manually set authorization, it will override the SAP Cloud SDK automatic token handling.
146150

147-
## Migration from Traditional Destinations
151+
### Migration from Traditional Destinations
148152

149153
Migrating from traditional destination configurations:
150154

151-
### Before (Traditional Destination)
155+
#### Before (Traditional Destination)
152156

153157
```java
154158
Destination destination = DestinationAccessor.getDestination("my-destination");
155159
HttpClient client = ApacheHttpClient5Accessor.getHttpClient(destination);
156160
```
157161

158-
### After (Transparent Proxy - Gateway)
162+
#### After (Transparent Proxy - Gateway)
159163

160164
```java
161165
TransparentProxyDestination destination = TransparentProxyDestination
@@ -164,7 +168,7 @@ TransparentProxyDestination destination = TransparentProxyDestination
164168
HttpClient client = ApacheHttpClient5Accessor.getHttpClient(destination);
165169
```
166170

167-
### After (Transparent Proxy - Destination)
171+
#### After (Transparent Proxy - Concrete Destination)
168172

169173
```java
170174
TransparentProxyDestination destination = TransparentProxyDestination
@@ -173,48 +177,17 @@ TransparentProxyDestination destination = TransparentProxyDestination
173177
HttpClient client = ApacheHttpClient5Accessor.getHttpClient(destination);
174178
```
175179

176-
## Troubleshooting
177-
178-
### Common Issues
179-
180-
1. **Missing destination name for gateway**: Ensure the destination name is provided as the first parameter to `.gateway(<destination-name>, <destination-custom-resource-name>.<destination-custom-resource-namespace>)`
181-
2. **Tenant context not available**: Verify tenant information is properly set in the request context
182-
3. **Authentication failures**: Check that authentication headers and parameters are correctly configured
183-
4. **Network connectivity**: Verify that the Transparent Proxy is accessible from your environment
184-
185-
### Evaluating Transparent Proxy Headers
186-
187-
When using proxy servers it can be difficult to troubleshoot issues as it is often not obvious where exactly the error occurred.
188-
For example, with the Transparent Proxy errors might occur on the target system (e.g. OData service), the Destination Service or the Transparent Proxy itself.
180+
## Approach 2: Transparent Proxy Loader
189181

190-
To make troubleshooting easier the Transparent Proxy adds additional response headers to provide more information about where an error occurred.
191-
For the above example of executing OData requests you can access the response headers as follows:
192-
193-
```java
194-
try {
195-
// execute OData request
196-
} catch (ODataResponseException e) {
197-
System.out.println(e.getHttpCode());
198-
// the Transparent Proxy will attach additional response headers in case an error occurred
199-
System.out.println(e.getHttpHeaders());
200-
}
201-
```
202-
203-
#### List of headers added by the Transparent Proxy
204-
205-
- `X-Error-Origin` - the source of the error
206-
- `X-Proxy-Server` - the proxy server (Transparent Proxy)
207-
- `X-Error-Message` - thorough error message
208-
- `X-Error-Internal-Code` - set only when the source of the error is the XSUAA or Destination service.
209-
The value is the HTTP code returned from one of these services.
210-
- `X-Request-Id` is sent with the response in all requests, both successful and failed
182+
The `TransparentProxy` class provides a `DestinationLoader` that enables routing **all destination traffic** through a single registered gateway host.
183+
This approach provides centralized proxy configuration where all destination requests are automatically routed through the configured gateway without requiring explicit destination builders.
211184

212-
For more information, see [Troubleshooting](https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/transparent-proxy-troubleshooting)
185+
### When to Use This Approach
213186

214-
## Transparent Proxy Loader
187+
Use the Transparent Proxy Loader when:
215188

216-
The `TransparentProxy` class is a `DestinationLoader` that enables routing all destination traffic through a single registered gateway host.
217-
This provides a centralized approach to proxy configuration where all destination requests are automatically routed through the configured gateway.
189+
- You want all destinations to automatically route through a single transparent proxy gateway
190+
- You prefer a centralized configuration approach
218191

219192
### Registration Methods
220193

@@ -253,6 +226,44 @@ TransparentProxy.register("<destination-gateway-host>", 8080);
253226
Destination destination = DestinationAccessor.getDestination("my-destination");
254227
```
255228

229+
## Troubleshooting
230+
231+
### Common Issues
232+
233+
1. **Missing destination name for gateway**: Ensure the destination name is provided as the first parameter to `.gateway(<destination-name>, <destination-custom-resource-name>.<destination-custom-resource-namespace>)`
234+
2. **Tenant context not available**: Verify tenant information is properly set in the request context
235+
3. **Authentication failures**: Check that authentication headers and parameters are correctly configured
236+
4. **Network connectivity**: Verify that the Transparent Proxy is accessible from your environment
237+
238+
### Evaluating Transparent Proxy Headers
239+
240+
When using proxy servers it can be difficult to troubleshoot issues as it is often not obvious where exactly the error occurred.
241+
For example, with the Transparent Proxy errors might occur on the target system (e.g. OData service), the Destination Service or the Transparent Proxy itself.
242+
243+
To make troubleshooting easier the Transparent Proxy adds additional response headers to provide more information about where an error occurred.
244+
For the above example of executing OData requests you can access the response headers as follows:
245+
246+
```java
247+
try {
248+
// execute OData request
249+
} catch (ODataResponseException e) {
250+
System.out.println(e.getHttpCode());
251+
// the Transparent Proxy will attach additional response headers in case an error occurred
252+
System.out.println(e.getHttpHeaders());
253+
}
254+
```
255+
256+
#### List of headers added by the Transparent Proxy
257+
258+
- `X-Error-Origin` - the source of the error
259+
- `X-Proxy-Server` - the proxy server (Transparent Proxy)
260+
- `X-Error-Message` - thorough error message
261+
- `X-Error-Internal-Code` - set only when the source of the error is the XSUAA or Destination service.
262+
The value is the HTTP code returned from one of these services.
263+
- `X-Request-Id` is sent with the response in all requests, both successful and failed
264+
265+
For more information, see [Troubleshooting](https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/transparent-proxy-troubleshooting)
266+
256267
## Related Documentation
257268

258269
- [HTTP Client](http-client) - For using destinations with HTTP clients

docs-java/features/connectivity/TransparentProxy

Whitespace-only changes.

0 commit comments

Comments
 (0)