Unfortunately we don’t have a lot of experience with combining java and SOAP, but one of our former colleagues did some experiments and got some basic functionality working using the ?singleWsdl URI parameter instead of ?wsdl. Below are his notes. Hope you can find it usefull - unfortunately we don’t have any further insights on it.
/Peter
To get started with Java, I used Eclipse, the important item was that I could use the Maven Framework, to import the wsdl file found at: http://localhost/ManagementServer/ServerCommandService.svc?singleWsdl (if you have it installed locally).
I know that NetBeans can be used but only know how Eclipse works so I’ll write this for Eclipse. If you really wanted then you could also use VS code, but it has some weird quirks, that I didn’t like so I went with Eclipse.
If you want to start a new project, then you can go to file → new → project… and find the maven folder.
Notes:
- To add the maven framework to eclipse you can do one of two things, the first is to go into eclipse click help → Install New Software → Add and then in the popup you want to fill out the name as M2Eclipse and the location as “http://download.eclipse.org/technology/m2e/releases” and then click ok.
- The second option is to click help → Eclipse Marketplace and in their search for Maven and find the one called something related to “Maven integration for Eclipse” click install and follow its steps.
- I found that there might be some weird payment plan in place for using JDK (java’s sdk) but you can use open JDK which is a open source version of JDK.
To import the file you might have to get the wsdl file locally on the machine, I had to copy paste everything from the site into a WordPad document cause if you downloaded it, it would put everything in one line and the import tool doesn’t like that. With as far as I got, I didn’t have to use these imported classes for much, but I guess they could become more important later in the process.
To import the file using the Maven framework you must create some connections in the pom.xml file that’s created when starting up a Maven project. I’m not 100% sure what connections is needed, but I do know that it was working with the ones I had. You need to make sure that the top lines in the file matches your project, they should by default. The rest can just be copied in, you set the location of the wsdl file at the top right after the default lines at:
<org.apache.cxf.version>3.1.3</org.apache.cxf.version>
<wsg.url>c:/temp/basic1.xml</wsg.url>
</properties>
To run the setup, you need to right click on the pom file and select run as → run configuration. And then select the Goals field and write “clean install” to clean up the files and then import the wsdl into the program. And if you want to see the full logs then you need to add “-X”.
You should get some errors because of the import tool not handling names to well. It should show which line conflict in the error message. The quick fix for this is to just change the naming inside the wsdl file on one of the two lines that conflicts, but the right way would be to find some way of handling this. The names of the lines that was conflicting was changed from:
<xs:element minOccurs=“0” name=“Reference” nillable=“true” type=“xs:string”/>
To for instance myReferance for the first of the places that the it complained about, and myOtherReferance for the other. For the purpose of this sample they shouldn’t be needed.
If you change the file and run again then you will then see a lot of new classes has been added into a folder “xprotectcsservercommand” found under src/generated/main/java/net/videoos/_2/…
If you instead want to import the project that I created, you must find it under Files → import → import existing project and chose the project. You must be careful when moving and changing the files of an eclipse project as they can break quite easy. Also, when having to move them out again you should delete it from the workspace just remember to uncheck the delete on disk, as having this unchecked will just remove it from the list of projects that eclipse will load up when opening the program.
After that I looked into a lot of ways to contact the server to get an answer back, in the beginning I tried to just call the “getServerVersion” from the generated classes but I kept on getting an unable to find valid certification path to requested target so first I looked into ways of adding authentication and so on to the call, but didn’t have any luck with that as the call it was making didn’t want to take any additional parameters.
In the end I investigated http and soap calls, but that proved to be a bigger challenge as well. For one I couldn’t find a way to connect to the server without authorizing myself with a valid basic admin account to the Xprotect management client. Besides that, I also needed to create a ssl socket where I also setup my “trustmanager” that accepts all certificates. I got the https calls to work, but still only if I authorize with a valid admin account, I didn’t have any luck in getting it to work with other ways of making the request. To get a response back you have to send it as a post request and to that end you need to supply it with a length value of its body, or else you get an error, you also have to make sure that the DoInput and DoOutput is set to true.