Skip to content

Commit 4765612

Browse files
Separate approaches
1 parent b7729d2 commit 4765612

File tree

1 file changed

+65
-55
lines changed

1 file changed

+65
-55
lines changed

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

Lines changed: 65 additions & 55 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,16 @@ 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.
189-
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
180+
## Approach 2: Transparent Proxy Loader
204181

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
215-
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.
187+
Use the Transparent Proxy Loader when:
188+
- You want all destinations to automatically route through a single transparent proxy gateway
189+
- You prefer a centralized configuration approach
218190

219191
### Registration Methods
220192

@@ -253,6 +225,44 @@ TransparentProxy.register("<destination-gateway-host>", 8080);
253225
Destination destination = DestinationAccessor.getDestination("my-destination");
254226
```
255227

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

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

0 commit comments

Comments
 (0)