I am using java to get a json file through URL, in the web browser it works but from my java code:
//I have used also timer:foo?period=5000 but not working
from("direct:start")
.multicast()
.to("http://" + URL)
.to("file:" + path + "&fileName=report");
Even if it does not display errors, camel does not create the file "report".
Any sugestion?
Thank you in advance.
Not sure I fully understand your goal, but it looks like you are trying to call a rest endpoint for a json response and then write that response to a file. In your example above camel is trying to write a file and call the http endpoint with the same message instead of getting a response from the http endpoint, then writing it to your report file. You can also update your timer to have the fixedRate property equal to true to keep calling.
You can do something like:
from("timer:foo?fixedRate=true&period=5000")
.to("http://" + URL)
.log("my response: ${body}")
.to("file:" + path + "&fileName=report");
Related
I’m trying to setup the emulator so I can develop the firebase functions safely before deploying them. I just noticed that some REST calls I’m doing now fails - anybody know if it is not possible to use the REST feature of the RealTime DB https://firebase.google.com/docs/reference/rest/database
I'm trying to hit it with this URL
http://localhost:9000/?ns=<PROJECT ID>-default-rtdb/development/DISHES.json
because this is what I set the firebaseConfig.databaseURL to (suggested here by Google)
Bonus info: If I try to do a GET to the URL via postman it creates another database called fake-server (http://localhost:4000/database/fake-server: null) 🤔
According to RFC 3986, the path must come before the query parameters in URLs. Your URL should be instead written as:
http://localhost:9000/development/DISHES.json?ns=<PROJECT ID>-default-rtdb
Note how the corrected URL has the query parameter appended to the very end. (The URL you've provided in the question will be parsed as having one query parameter ns with the value of <PROJECT ID>-default-rtdb/development/DISHES.json, which is not a valid namespace name. That explains the errors you've seen.)
FYI, it looks like you're constructing the URL by concatenating the string databaseURL with the path -- this may lead to surprising results as you've seen above. Considering using a URL parser / formatter in your language / framework of choice instead, which handles URL parts correctly. For example, in JavaScript you can use the snippet below:
const url = new URL(databaseURL); // Parse URL (including query params, if any)
url.pathname = '/development/DISHES.json';
yourFetchingLogic(url.toString()); // Reconstruct the URL with path replaced
i am using Swagger-ui version 2.1.4, i have hosted it locally and provided it my own Json file and API it opens the document fine and lists all the method in the json file, after i put basic authentication in it, i did all changes in the Index.html changes are
function addApiKeyAuthorization(){
var key = "Basic ************";
if(key && key.trim() != "") {
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", key, "header");
window.swaggerUi.api.clientAuthorizations.add("Authorization", apiKeyAuth);
swaggerUi.api.clientAuthorizations.add("Authorization", apiKeyAuth);
}
}
it gives error, screen shot attached.
it gives error when it tries to authenticate swagger get data of the method with anonymous permissions from same API.
When i hit the Curl from the command prompt it bring results. It only fails in Swagger
Did Swagger have any issue with basic Authentication?
You might open up Fiddler and make the request via the browser, like you said you did, and then make the request using Swagger 2.0. Compare the requests and make 100% sure the request headers and url are the same.
I'm trying to send a file to a user from an http servlet.
The servlet runs some identification tests (on the request) and then sends the client a file.
This generally works but now I turned on my TOMCAT server redirects to https and when I try to access the servlet and download the file from either IE6 or IE8 it fails and I get this exception:
java.lang.IllegalStateException: Cannot forward after response has been committed
(on the localhost.log)
and
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
(in the servlet log)
The code that does the sending (Simplified):
private void sendFile(HttpServletResponse response, byte[] file, String clientFileName)
{
ServletOutputStream op = null;
setContentType(response);
response.setHeader("Content-Disposition", "attachment; filename=\"" + clientFileName + "\"");
// send byte array to output buffer.
op = response.getOutputStream();
// Content Length must be set after all processing done.
response.setContentLength((int) file.length);
op.write(file);
}
Is this the correct way to send a file from a servlet? What's the best way?
Thanks!!
UPDATE
Used the code from #BalusC artice in this link:
http://balusc.blogspot.com/2007/07/fileservlet.html
This made it work.
Still doesn't work in IE6-IE8 when used from Gmail because of a filtering stage gmail adds to downloads in these browsers.
UPDATE 2
The problem seems to be with Gmail + Internet Explorer 6-8.
I'm Assuming that gmail is doing a redirect (That's actually pretty obvious if you look at the url on the page after you click the link in the mail).
Is Client-Pull technique my only solution?
The solution to the problem is the "Client-Pull" technique.
By adding a Refresh value to the header we make the browser ask for the file.
This is the only solution I could come up to that overcomes the fact the gmail will use redirection when pressing a link from within an email.
In the code I did this:
response.setHeader("Refresh", "3; URL=\"" + url.toString() + "\"");
forwardToJSP(request, response, "waitForBrowserRefreshPage.jsp");
Meaning - after 3 seconds ask the user for the specified url which will, in turn, deliver the file to the client.
The forwardToJSP method displays the "You will be forwarded soon, here a link if it fails" message.
I created an ASHX file and use it to handle async file uploads.
Since the site might not be hosted on our servers, I want to check for write permissions and delete permissions and supply the end user (site content editor in this case) with an error they can deal with.
I'm using uploadify for the upload, I'm not sure, but I`m guessing this complicates the return of a message that can be shown on the page, but maybe not.
I ended up using the c# code in ashx file to check for permissions on the directory and returned different status codes as JSON objects.
context.response.write("{success: 'false', message: '" + ex + "'}")
And in the client side JS I just access response.message if response.success = false.
Everything works well.
Thank you!
Before the user is able to attempt an upload, trying writing and reading a small file to the destination on the server (on the server side), if this fails then you can supply them with an appropriate message.
I have a remote RSS feed which has to be transformed into Notes documents using LotusScript.
I've looked through the documentation, but I can't find how to open a remote URL in order to retrieve its contents. In other words, some sort of wget- or curl-like functionality. Can anyone shed some light on how to do this? Using Java is not an option.
Thanks.
Check out the NotesDOMParser class - available in LotusScript - which lets you (indirectly) pull XML from a remote URL and process in a an XML DOM object.
You can pull the XML into a string using the MSXMLHTTP COM object, then use NotesStream to send the XML to the NotesDOMParser.
I have not tested, but the code would look something like this:
...
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.open "GET", sURL, False, "", ""
objXML.send("")
sXMLAsText = Trim$(objXML.responseText)
Set inputStream = session.CreateStream
inputStream.Open (sXMLAsText)
Set domParser=session.CreateDOMParser(inputStream, outputStream)
domParser.Process
...
Documentation: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/H_NOTESDOMPARSER_CLASS.html
You can't open a remote URL (whether it's HTTP or some other protocol) using native Lotusscript: the object library simply doesn't support it. If you're running on a Windows server, you should be able to use the MS XMLHttp DLLs to get a handle on your remote file via a URL, as specified by the previous answer. (Alternatively, this link specifies how to parse and open a UNC path with Lotusscript—again, Windows only).
All that said, if I understand you correctly, you're not using HTTP to access the remote file at all. If the RSS file is just on a simple path, why can't you open the file for parsing in the normal way with Lotusscript?