| Back | Main view
Generating Java client source code using JAX-WS with embedded wsdl for accessing IMiS ARChive server administration module
Product: | IMiS/ARChive |
Release: | Since 9.5.1510 |
Date: | 04/21/2023 |
Case:
IMiS ARChive server administration module uses SOAP protocol for communication with administration module. In this article we represent a way to generate Java client using JAX-WS with embedded wsdl file.
Description:
IMiS ARChive administration module listens by default on port 16808. WSDL can be retrieved by accessing url "https://iarc-server-url:16808/admin?wsdl". Because IMiS ARChive Server by default uses self-signed certificate, accessing WSDL will most probably fail with "MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT" error in Mozilla Firefox or "NET::ERR_CERT_AUTHORITY_INVALID" in Microsoft Edge. Continuing to the provided url will require authentication, you can authenticate with any user which has enabled "Local over HTTP" options. You can also retrieve wsdl by using openssl and curl.
Get certificate chain from administration server in PEM format:
echo "" | openssl s_client -connect iarc-server-url:16808 -showcerts 2>/dev/null | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' > ca_bundle.pem
Retrieve wsdl file from server using digest authentication:
curl --digest --cacert ca_bundle.pem --user http-enabled-user https://iarc-server-url:16808/admin?wsdl > administration.wsdl
Generating Java source code using wsimport command:
wsimport.exe -Xnocompile -p java.client.package.name -wsdllocation wsdl/administration.wsdl -s "/full/path/to/output/directory" "/full/path/to/administration.wsdl"
Wsimport may fail with multiple errors. This errors came up while generating Java source code for IMiS ARChive 10.1.2010 wsdl file:
[ERROR] Property "DetailedDescription" is already defined. Use <jaxb:property> to resolve this conflict.
line 1415 of file:/full/path/to/administration.wsdl
[ERROR] The following location is relevant to the above error
line 1419 of file:/full/path/to/administration.wsdl
[ERROR] Property "Mandate" is already defined. Use <jaxb:property> to resolve this conflict.
line 1416 of file:/full/path/to/administration.wsdl
[ERROR] The following location is relevant to the above error
line 1420 of file:/full/path/to/administration.wsdl
One way to resolve this kind of errors is to write external binding file. Next example demonstrates how to resolve naming conflict. "DetailedDescription" is renamed to "DetailedDescriptionValue", "Mandate" is renamed to "MandateValue".
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="administration.wsdl#types?schema1">
<jaxb:bindings node="//xsi:schema/xsi:complexType[@name='RetentionPolicyUpdate']/xsi:sequence/xsi:element[@name='DetailedDescription']">
<jaxb:property name="DetailedDescriptionValue"/>
</jaxb:bindings>
<jaxb:bindings node="//xsi:schema/xsi:complexType[@name='RetentionPolicyUpdate']/xsi:sequence/xsi:element[@name='Mandate']">
<jaxb:property name="MandateValue"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
Save binding instructions to the same location as "administration.wsdl" (for example "administration-binding.jaxb") and run wsimport again with "-b" option:
wsimport.exe -Xnocompile -p java.client.package.name -wsdllocation wsdl/administration.wsdl -s "/full/path/to/output/directory" -b "/full/path/to/administration-binding.jaxb" "/full/path/to/administration.wsdl"
Related Documents:
https://javaee.github.io/metro-jax-ws/
https://en.wikipedia.org/wiki/SOAP
https://www.w3.org/TR/2001/NOTE-wsdl-20010315
https://docs.oracle.com/javase/tutorial/jaxb/intro/custom.html
https://docs.oracle.com/cd/E23943_01/web.1111/e13758/data_types.htm#WSGET180
https://jcp.org/en/jsr/detail?id=222
| Back | Main view