xively java client returns status code 401 - java

Trying to learn the Java interface to Xively. The following simple test fails with a 401 status code:
Feed myFeed = XivelyService.instance().feed().get(2126903832);
The exception statement is
com.xively.client.http.exception.HttpException: Http response status
indicates unsuccessful operation[Status code: 401.; Reason:
{"title":"Unauthorized","errors":"You do not have permission to access
this resource"} ]
The following console line leads me to believe that I'm not setting up the API key correctly:
2013-10-21 18:58:17,925 506 DEBUG [DefaultClientConnection.java:
276] (main:) >> X-ApiKey:
The Developer docs says replace <your api key> in config.properties with my API key. I did that, but it doesn't seem to make any difference.
I installed the library with Maven to my default Maven repo and point to it in Referenced Libraries. I am trying to build the whole thing in Eclipse.
My specific question is where is the config.properties the ApiConfig is reading?

I had this problem too. The problem was that I had double quotes in the config.properties file. The line should read:
api.key=yWYxyi3HpdqFCBtKHueTvOGoGROSAKxGRFAyQWk5d3JNdz0g

Related

Client ID must be set as api.adwords.clientId in ads.properties. AdWords on GAE

I have a Java program that makes reports from Google AdWords, the authentications are working correctly since I have no issues issuing my reports with the Java API, but now when I run my Java API on the localhost with mvn appengine:devserver, it gives me this exception:
Client ID must be set as api.adwords.clientId in ads.properties.
If you do not have a client ID or secret, please create one in the API console: https://console.developers.google.com/project caused by: [clientId]
Only thing I change from the Java app to the GAE app is the doGet method, I comment it out and change my run() that is called by the doGet to main(String args[]).
Fixed, here's how:
This issue is due to the path of properties file.
First when deploying app, I was using a server so it doesn't read the properties file from the same directory as when it's run (ran?) on eclipse with the play button or with javac your_java_app.java
I moved my ads.properties from resources to src/main/webapp/WEB-INF and changed the OAuth2Credential from
..fromFile().. to
..fromFile("WEB-INF/ads.properties")..

webservices - wsimport hangs on parsing WSDL

These are my environment variables:
System variables:
JAVA_HOME C:\Program Files\Java\jdk1.8.0_20\
Path:
...;C:\Program Files\Java\jdk1.8.0_20\bin;...
I key the following in the command line:
c:\wsimport>wsimport http://www.webservicex.net/geoipservice.asmx?WSDL -Xdebug
I receive the following message
[DEBUG] Authorization file "C:\Users\myPC.metro\auth" not found. If
the WSDL access needs Basic Authentication, please provide
authorization file with read access at C:\Users\myPC.metro\auth or
use -Xauthfile to give the authorization file and on each line
provide authorization information using this format : http[s]://user:password#host:port//
parsing WSDL...
Where my configuration is incorrect?
I am not sure what happened but it's working now. It seems like my issue was perhaps related to my internet connection. I was online but the connection was pretty slow. Now everything's back to normal and my wsimport command is working.

TCLBLEND FAILURE - Centos 6.4

I have been trying to use a home grown test tool and after doing an update to Centos 6.4, I am no longer able to run the tcl based tool. I am getting the following error and I have no internet access on this server. Kindly advise how do I solve this problem?
Thanks
"XpUtils::iload -d /usr/local/testtool/repo/package/linux-glibc2.3-x86_64/lib/tcljava1.4.1 tclblend" failed:
couldn't load file "/usr/local/testtool/repo/package/linux-glibc2.3-x86_64/lib/tcljava1.4.1/libtclblend.so": libjava.so: cannot open shared object file: No such file or directory
while executing
"error "\"XpUtils::iload -d $dir tclblend\" failed:\n $errMsg""
(procedure "loadtclblend" line 168)
invoked from within
"loadtclblend /usr/local/testtool/repo/package/linux-glibc2.3-x86_64/lib/tcljava1.4.1"
("package ifneeded java 1.4.1" script)
invoked from within
"package require java"
("eval" body line 1)
invoked from within
"eval package require $pkg"
("foreach" body line 2)
invoked from within
"foreach pkg $pkgList {
set ::${pkg}Version [eval package require $pkg]
}"
(file "/usr/local/testtool/testtool" line 165)
If you read the error message trace, you'll see that it says that this is all caused by:
libjava.so: cannot open shared object file: No such file or directory
The first steps would then be to ensure that you've got a version of Java actually installed, to check that it includes the file libjava.so, and that the file has been indexed by the system shared library catalog.
It might also be worth checking that all its dependencies are also present and that you've got the architecture for the Tcl library and the Java library matched (e.g., both 32-bit) as those can cause odd failures when they go wrong.

Writing CGI script in Java

I trying to figure out how to write CGI scripts in Java.
I followed this examples -> http://www.javaworld.com/jw-01-1997/jw-01-cgiscripts.html?page=1
It provide cgi_lib.java, hello.html and hello.java
Everything seems fine, but in the html part.
The action is pointed to cgi_lib/hello.cgi
There's no cgi provided. So I tried with cgi_lib/hello.java, and it print the entire source code in the hello.java.
Then i tried to edit the hello.java extensions into hello.cgi, and tried again.
The browser returns me error 500.
What is the problem?
Is it that, there's some specific method to compile the hello.java into hello.cgi?
The script in hello.cgi is different from hello.java?
Please help.
Thank you.
UPDATE
I added hello.cgi
#!/bin/sh
java -Dcgi.content_type=$CONTENT_TYPE -Dcgi.content_length=$CONTENT_LENGTH - Dcgi.request_method=$REQUEST_METHOD -Dcgi.query_string=$QUERY_STRING -Dcgi.server_name=$SERVER_NAME -Dcgi.server_port=$SERVER_PORT -Dcgi.script_name=$SCRIPT_NAME -Dcgi.path_info=$PATH_INFO hello
So is the $CONTENT_TYPE, $CONTENT_LENGTH,... remain the same? Or should I enter something?
Just to make things clearer.
I put the the cgi_lib, hello.java and hello.cgi in the C:\xampp\cgi-lib
And the hello.html in C:\xampp\htdocs\test
When I tried to connect it returns me this
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
couldn't create child process: 720002: hello.cgi
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
I had check the httpd.conf in c:\xampp\apache\conf and configure according to this
LoadModule cgi_module modules/mod_cgi.so
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
Seems to be already enable.
So whats the problem right now?
The contents of hello.cgi is shown at the top of page 2 of the article.
#!/bin/sh
java -Dcgi.content_type=$CONTENT_TYPE -Dcgi.content_length=$CONTENT_LENGTH -Dcgi.request_method=$REQUEST_METHOD -Dcgi.query_string=$QUERY_STRING -Dcgi.server_name=$SERVER_NAME -Dcgi.server_port=$SERVER_PORT -Dcgi.script_name=$SCRIPT_NAME -Dcgi.path_info=$PATH_INFO hello
The article says that you will execute the java jar from within a cgi script. You need to make sure that this script is set up to execute your jar file by making the correct calls to the java executable with your hello.jar file as the parameter. Also make sure your web server is configured correctly to allow the execution of cgi scripts.
You also have to chmod of your cgi and java files so others can execute them.

wsimport Xauthfile error

I am trying to generate the java help classes that I need for a client (a.k.a consumer) for a SSL-protected web service (on Microsoft Biztalk) that is external to our company network. We can access it only over a proxy and we cannot change anything about the Webservice itself.
This is my command provided to the wsimport tool:
wsimport -keep -httpproxy:theProxy.net:8080 -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it -Xauthfile c:\generatedWebService_wsImport\auth https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
and this is the content of my auth file:
https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
And this is the error I get:
[ERROR] Server returned HTTP response code: 401 for URL: https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL,
"https:
//meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL"
needs authorization, please provide authorization file with read
access at C:\Documents and Settings\s6424.metro\auth or use
-Xauthfile to give the authorization file and on each line provide authorization information using this format :
http[s]://user:password#host:port//
Of course the proxy and credentials are different as in this post. The password contains a special character ! (exclamation mark).
Can someone help me with a working example under similar conditions. I had already searched a lot but couldn't find anything that would have helped me.
Is there somewhere a downloadable source code of the wsimport tool? This would be as the last resort to use.
Try to open https://user:pwd#meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
with your browser and save to local folder. Later you can use a wsimport like this:
wsimport -keep -s c:\generatedWebService_wsImport\ -p the.java.package.I.want.to.call.it /home/user/Download/example?WSDL
Regards,
in your request, you used
https://meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
in your auth file, it is
meldeservice-test.oekb.at:8080/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL
try removing the port number, change it to
https://user:pwd#meldeservice-test.oekb.at/Meldeservice/WebService_at_oekb_biztalk_MeldeService.asmx?WSDL

Categories