如何使用JDeveloper在OSB中创建适配Servlet端点的HTTP业务/代理服务
Got it, let's walk through how to set up your OSB Business Service and Proxy Service in JDeveloper to connect with that POST-based Servlet endpoint that returns a byte array. I’ve done this dozens of times, so here’s a clear, step-by-step breakdown tailored to your scenario:
1. 创建业务服务(Business Service)
This is the OSB component that directly communicates with your Servlet endpoint:
- Open JDeveloper and switch to the Service Bus perspective (go to
Window > Open Perspective > Service Busif it’s not already active) - Right-click your OSB project in the Application Navigator, then select
New > Business Service - Give your service a meaningful name (like
MyServletBusinessService) and click Next - On the Transport tab:
- Select
HTTPas the transport protocol, then click Next - Configure the HTTP settings:
- Set the Method to
POST - Enter your Servlet’s full endpoint URI in the field (e.g.,
http://your-server:8080/your-web-app/your-servlet-path) - Click Next
- Set the Method to
- Select
- On the Message Type tab:
- Since your Servlet returns a byte array, set both Request Message Type and Response Message Type to
Binary(this tells OSB to handle the data as raw byte streams instead of trying to parse it as XML/JSON) - Click Next
- Since your Servlet returns a byte array, set both Request Message Type and Response Message Type to
- Skip through the remaining tabs (keep default settings unless you need custom configurations like security) and click Finish
- Optional: Head to the Configuration tab of your new business service, go to
Transport Details > HTTP > Request Headersto add any required headers (likeContent-Type: application/octet-stream) if your Servlet expects specific headers
2. 创建代理服务(Proxy Service)
This is the endpoint your clients will call, which routes requests to the business service we just created:
- Right-click your OSB project again, select
New > Proxy Service - Name it something client-friendly (like
MyServletProxyService) and selectBusiness Serviceas the service type, then click Next - Choose the business service you created in step 1 from the list, click Next
- On the Transport tab:
- Select
HTTPas the transport protocol - Enter a custom endpoint URI for clients to access (e.g.,
/api/my-servlet-proxy) - Click Next
- Select
- On the Message Type tab, match the settings from your business service: set both request and response types to
Binary - On the Message Flow tab, the default routing (direct to the business service) works fine here—no need for extra transformations since we’re dealing with raw bytes
- Click Finish to create the proxy service
3. 关键验证与测试
- Deploy your OSB project to your Service Bus server (right-click the project >
Deploy > [Your OSB Server]) - Test the proxy service using a tool like Postman or
curl:- Send a POST request to the proxy’s endpoint (e.g.,
http://osb-server:7001/your-project/api/my-servlet-proxy) - If your Servlet returns a file or other binary data, verify that the response is correctly received as a byte stream (e.g., download the response and check if it’s intact)
- Send a POST request to the proxy’s endpoint (e.g.,
- Use the OSB Console to monitor requests/responses if you run into issues—check for any header mismatches or transport errors
内容的提问来源于stack exchange,提问作者Arasu
相关产品推荐
相关产品推荐

