Generating Metro Client Using Local WSDL File - wsdl

I have generated a Metro client using wsimport before, but in that case the WSDL was accessed over https. My commaned looked like this:
wsimport https://service.net/services/Service?wsdl -d C:\ClientProject\src\main\java -keep
and everything worked fine. Now I am trying to generate a client, however, I only have a local copy of the WSDL file. My project directory is set up like this (in c:\Devel):
ClientProject
|- src
|- main
|- java
|- resources
|- META-INF
|- service.wsdl
|- wsimport.bat
The wsimport.bat file looks like this:
wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
which was based on the Metro Guide example but without the -p option (http://metro.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html). However, when I run the bat file, I get an endless loop of of the command being printed to the console. E.g.
C:\Devel\ClientProject>wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
Can somebody point out what I'm doing wrong?
UPDATE
I have tried using absolute paths (and rearranging the param order to no avail. I still get the endless command console prints:
wsimport C:\Devel\ClientProject\src\resources\META-INF\service.wsdl -d C:\Devel\ClientProject\src\main\java -keep

http://www.java.net/forum/topic/glassfish/metro-and-jaxb/problems-generating-client-using-local-wsdl-file#comment-812705
If using a .bat file to run the wsimport command, do not name it wsimport or you'll be in an endless recursive loop calling that file.
Also, "-wsdllocation" is case sensitive. "-wsdlLocation" will not work (although I've seen many examples of it during my searches).
This wsimport command generates the client code from the local WSDL and sets the "wsdlLocation" attribute on the Service class' #WebServiceClient annotation:
wsimport src/resources/META-INF/service.wsdl -keep -d src/main/java -wsdllocation META-INF/service.wsdl

Related

Running CQL file in Neo4j

I have a CQL file called Novis.cql. Its somewhere random on my harddrive, but I want to run it in Neo4J to create my graph (it contains 500+ lines of code).
Where do I have to place it? And what command do I have to run nowadays to get it working? I've read and searched for answers, but some of the commands like Neo4jshell dont seem to work any longer...
Any help would be very appreciated!
The cypher-shell tool has been available for a while (starting with version 3.0, if not earlier), and you can use it to execute a Cypher query from a file that can be anywhere in your file system.
For example (on a linux/unix system), a command line like this will work (if you are in the neo4j home directory):
cat /my/full/path/my_code.cql | bin/cypher-shell -u neo4j -p secret
In neo4j 4.0 a new -f option was added to make it simpler:
bin/cypher-shell -u neo4j -p secret -f /my/full/path/my_code.cql

ab: Could not read POST data file: End of file found

I am getting the error in the title when trying to run Apache Bench to test a HTTP endpoint I wrote, but only when specifying a POST file with contents. If I specify an empty file to -p.
I have been trying various solutions found online regarding the encoding and format of the contents, but it seems like just about any content will get this error.
The problem was that when installing Apache Bench from source, I had copied over the ab executable file from httpd/support/bin/.lib/ab to ~/.local/bin. When I did that, it used the system-wide libapr instead of the one I had downloaded to httpd/srclib/apr. This caused some sort of version mismatch, I assume.
The solution was to remove my copy of ab from ~/.local/bin and instead create a script ~/.local/bin/ab with contents
#!/bin/sh
$SRC/httpd/support/ab "$#"
and make this executable with chmod a+x ~/.local/bin/ab.

How to use swagger code-generator

I am working on creating the rest client and I will be calling an API which gives this big json output .I want to know how to create the Pojo classes automatically by inputting this json to swagger code gen and let it create my pojo classes for me which will save manual time . Here is what I have tried
To generate a PHP client for http://petstore.swagger.io/v2/swagger.json, please run the following
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l php \
-o /var/tmp/php_api_client
(if you're on Windows, replace the last command with java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client)
I could not get pass the mvn clean package and it is giving the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project swagger-codegen: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: io/swagger/models/properties/Property
Anyone have successfully used this swagger ? or even if you can suggest any other framework which can do this functionality would be of great help . Thanks in advance ..,
I seen the following link
Update code generated by Swagger code-gen
and able to run the application .. Can anyone explain if I can use this to get the pojo object created for the json input?
Your problem is not swagger itself. Your problem comes from maven and it says that it can't find a certain class. I downloaded the repo and it compiles on my machine with mvn validate package. Make sure you have .m2\repository\io\swagger\swagger-models... in your standard maven cache directory. Thats the dependency, which has the Property class.
Actually maven should download it right before compiling. Check the maven output for connection errors or unreachable downloads etc.

Override rpmbuild build location when called from command line

I am making some config packages which are built by Jenkins, then checked out whenever they are needed. The package itself is built and runs fine. My problem right now is the directories that rpmbuild uses for actually building the project. When I call rpmbuild SPECS/package.spec from my working directory, rpmbuild makes a new directory at /home/user/rpmbuild. This was fine when I was running tests but I would rather that I just be able to build from whatever file it is called from for the Jenkins process.
I see online people saying to make a ~/.rpmmacros file to overwrite the $_topdir variable. That approach isn't really working for the Jenkins build. Is there some way to simply call rpmbuild and build in the current directory? The structure is all there and it would work better for what I am trying to do. Thanks.
Yes, just override _topdir directly.
rpmbuild -D '_topdir /new/value/for/_topdir'
or
rpmbuild --define='_topdir /new/value/for/_topdir'
those should be identical but I've learned that they aren't always for some reason (and in quick tests rpm -D '_topdir /opt/tnstmp' --showrc | grep _topdir doesn't show the modified value but rpm --define '_topdir /opt/tnstmp' --showrc | grep _topdir did).

Upload XML file to server on another machine

How can I upload a XML file that resides on a computer (let's call it workstation) onto a BaseX server that runs on another computer (server)?
To upload a XML file to the BaseX server on workstation I use
basexclient -n localhost -d -w -c "CREATE DATABASE ${db_name} ${file}"
When the hostname is changed from localhost to server, this command fails with
org.basex.core.BaseXException: Resource "[complete FILE path]" not found.
IIUC, the error happens because this command does not upload the XML file itself, but just asks the server to read it from the path ${file}. The command then fails because ${file} is not available on server but only on workstation.
What command should I use to upload the XML file to the remote server?
(Obviously without copying the file to the server and then executing the command locally on the server.)
Assuming that -n means what you seem to be using it to mean, and that a local client can in fact communicate with a remote server, and assuming also that your XML document is a standalone document, I'd try something like the following (not tested), with $server, $dbname, $file, and $baseurl defined as environment variables:
(echo CREATE DATABASE ${dbname};
echo ADD TO ${baseurl};
cat ${file};
echo EXIT ) | basexclient -n myserver -d -w
But otherwise I'd use the BaseX HTTP server and use curl or wget to sent a PUT request with the file to the address http://myserver.example.org:8984/webdav/mydb/myfile.xml (and of course, if necessary, I'd use curl multiple times to make the database and then add data to it).

Resources