{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1
Question by P.Ganesan · Jul 03, 2015 at 10:21 AM · 1.3k Views java calloutcertificatesjavakeystore

Java Callout - Read external files in Java

Hi! In Java Callout, I tried to include the java keystore file (.jks) to overcome the SSLHandShakeException but I was not able to deploy API bundle, It shows some server exception. Similarly how to read the properties in config. file in Java Callout? Please Advise. Thanks.

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

1 Answer

  • Sort: 
avatar image
2
Best Answer

Answer by berraquera · Jul 03, 2015 at 04:46 PM

Dear @P.Ganesan, for security reasons reading files from the filesystem is not allowed from Java Callout policy. However, you can still leverage Java streams to read text or binary files stored in jar files. For a full api proxy example, please leverage the following tutorial. Let me know how it goes! Cheers!

InputStream fstream = this.getClass().getResourceAsStream("/templates/stockTemplate.xml"); //read stockTemplate.xml as a class from classpath
StringWriter writer = new StringWriter();
IOUtils.copy(fstream, writer, "UTF-8");
String theString = writer.toString();
messageContext.setVariable("stockTemplateFileContent", theString); //assign file content to stockTemplateFileContent variable
messageContext.setVariable("response.content", theString); // assign file content to response.content variable
return ExecutionResult.SUCCESS;
Comment
Add comment Show 2 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robin wilkins · Mar 01, 2017 at 05:58 PM 0
Link

It would be very useful to be able to read files from the proxy resources directory, and if it was possible to store a wider range of file types in the resources folder

avatar image Dino ♦♦ robin wilkins   · Mar 01, 2017 at 06:00 PM 0
Link

I agree completely, Robin!

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The variable reference request.queryparam.email in java callout property is not working. 2 Answers

What version and type of Java Jar files are loaded? 2 Answers

Failed to instantiate the JavaCallout Class 1 Answer

JavaCallout error "Failed to instantiate the JavaCallout Class apigee.test.TestJavaProject" 3 Answers

Java callouts limitations. Difference between Cloud customers and Private Cloud customers. 2 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges