Generating Code from WSDL

Hello,

I am trying to generate Java code from the WSDL using Wsimport tool.

This does not work because typedefinitions are duplicate.

I could comment it out, but that’s not the idea.

Has anyone already made a Java integration and can give me a hint / trick to use the original WSDL files?

Many thanks for help.

Thomas

Edit: Is it possible that the files in the current SDK (MIPSDK_Installer_2019R2.msi) are not up-to-date? I find references to dkws-jsl-01, which are fixed according to https://developer.milestonesys.com/s/question/0D50O00004U1rzPSAR/on-uploading-alarmcommandtokenwsdl-in-soap-editor-using-smartbear-getting-the-following-error-error-message-javanetunknownhostexception-dkwsjsl01-please-suggest.

Frist of all, please make sure to check if your setup is correct.

Unfortunately the only thing that we can suggest for now it to change the file, so you won’t have the type definitions conflict.

Thank you for your reply.

I have taken the WSDL files from the installed setup. On the computer itself, the setup is not installed because it is a Linux system.

I postponed the problem at the moment. I just want to establish the connection to the ManagementServer at first. The errors are in other files.

Here I have a new problem.

I am unable to connect the server based on the WSDL files from the SDK. If I query the WSDL files from the server itself, the namespaces are completely different. (“http://videoos.net/2/XProtectCSServerCommand” <> “http://tempuri.org/”)

Is there an explanation ? Unfortunately, I am not the WSDL specialist. And the installer of the Milestone system can not help me.

Attached are the different files:

ServerCommandService_SDK.wsdl the file from the SDK

ServerCommandService_server.wsdl received from server by http://192.168.1.151/ManagementServer/ServerCommandService.svc?wsdl

ServerCommandService_single.wsdl received from server by http://192.168.1.151/ManagementServer/ServerCommandService.svc?singleWsdl

New explanation:

If I use the deprecated URL http://192.168.1.151/ServerAPI/ServerCommandService.asmx it workes with the WSDL from the SDK.

The new URL http://192.168.1.151/ManagementServer/ServerCommandService.svc has the wrong Namespace and don’t work.

What did I misunderstand ?

What needs to be done differently for the new URL ?

If you use E-code products then URL http://192.168.1.151/ServerAPI/ServerCommandService.asmx works.

If you use C-code products then URL http://192.168.1.151/ManagementServer/ServerCommandService.svc works.

According to your last comment, you might use Ecode product.

No. We use a C-code system and the URL ist also in the official documentation. See

attachment.

Can you please try and see if you can connect with Basic user over SSL?

Because we got that to work on our installation.

I tested it and I also tested it with another system.

The behavior is unchanged. It comes the wrong namespace (also over SSL / BASIC user).

Does something else have to be configured on the server if you want to use the interfaces?

I can observe the same WSDL’s as you can. I will try to find answers..

I had to consult developer colleagues and this is what I got, hope it fits..

You can consume https:///ManagementServer/ServerCommandService.svc from other environments as long as you use a basic user for login through basic authentication. You will probably have to generate your own proxy client, but most languages come with tools for that (just add ?wsdl to previous mentioned URI). One example on how to do this (in Java) can be found here (step 3): https://www.codeproject.com/articles/777036/consuming-wcf-service-in-java-client

Thank you for the analysis and explanation.

I was unsure if this is OK, because the namespace is a bit strange and the WSDL files are not in the SDK. But you have now confirmed that it is OK.

I have already tried to create from these files client proxy code. It also works for most of the files in the SDK, and I’m also using it successfully for the deprecated interface.

Since Java 11 the tool is no longer integrated and you have to use third party tools.

For some SDK files and also the ServerCommandService file of the new interface it does not work yet.

Every code generator I’ve tried so far breaks down with an error. For example, the code generator wants to create from different definitions proxy code with the same name, which does not work.

And that brings us back to the original problem. Is it known whether there is already a successful integration of the new interface in Java? If so, which framework / code generator was used?

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.

Thank you for the informations. They confirm our results.

I got the WSDL translated with a special binding-file and corresponding mappings.

I was also able to establish a connection using SSL and BASIC authentication to https:///ManagementServer/ServerCommandService.svc.

The connection via AD authentication does not work with it. (tried via http or https)

That should also work according to documentation.

The AD authentication must be used by our customer and it is also required to query the site info (http:///RCServer/SiteInfo.xml).