CXF Web Services Java Sample
search cancel

CXF Web Services Java Sample

book

Article ID: 432137

calendar_today

Updated On:

Products

CA Service Desk Manager CA Service Management - Service Desk Manager

Issue/Introduction

The following document serves as a way to introduce users to the CXF SOAP web service by usage of the built in sample packages.  We will describe how to obtain and configure the packages in order to successfully compile and run a sample CXF program.  Such content may assist developers who wish to review a working Java sample code package for use in their own development activities.

The sample that is being used is NX_ROOT\samples\sdk\cxfwebsvc\java\test3_attachments, file create_attachment.java.  

Execution of the create_attachment.java sample will entail running the following three methods defined in CXF Web Services:

  • Login to SDM.  Method:  login
  • Creating a Request ticket.  Method:  createRequest
  • Attaching sample file "test_upload_file.txt" to the new ticket.  Method:  createAttachment

Environment

Release:  17.4 GA and above
CA Service Desk Manager

Resolution

The following should be performed on a non-production based Service Desk Server instance which has access to the CXF web services via the following URL from the web browser situated on the SDM Server:

http://localhost:8080/cxf/services/USD_WebService?wsdl
  1. Download the Apache CXF Binary distribution.  The recommended version should be a 3.6.x release.  In the running example, we will use Apache CXF 3.6.10, file apache-cxf-3.6.10.zip.

  2. Extract the Apache CXF Binary and place in a suitable location on the SDM Server.  In our running example, it will be placed in C:\apache-cxf-3.6.10.  The directory structure should look like this:



  3. Access the samples directory:  NX_ROOT\samples\sdk\cxfwebsvc\java

  4. Copy the run_java_test_bat.txt file to a new folder, eg:  C:\java-cxf-sample

  5. Access the test3_attachments folder, NX_ROOT\samples\sdk\cxfwebsvc\java\test3_attachments

  6. Copy the create_attachment.java and test_upload_file.txt to the same C:\java-cxf-sample folder, where run_java_test_bat.txt was previously copied.

  7. Edit file run_java_test_bat.txt in a text editor.

  8. Comment the following (line 11):
    Original:  @SET TEST_APP=JWS
    Revised:  ::# @SET TEST_APP=JWS

  9. Uncomment the following (line 13):
    Original:  ::# @SET TEST_APP=create_attachment
    Revised:  @SET TEST_APP=create_attachment

  10. Adjust the following lines to the relevant directory locations for your SDM instance:
    Line 17:  @SET USD_SHORT_PATH=C:\PROGRA~2\CA\SERVIC~1
    Line 23:  @SET CASHCOMP=C:\PROGRA~2\CA\SC
    Line 26:  @SET CXFLIBPATH=C:\apache-cxf-3.4.5\lib
    Line 33:  @SET JAVA_PATH=C:/PROGRA~2/CA/SC/JRE/11.0.18

    Note:  make sure to use the 8.3 notation file paths rather than long file names.  "C:\PROGRA~2" vs "C:\Program Files (x86)" for instance.
    The CXFLIBPATH variable should point to the Apache CXF Distribution's lib subdirectory.

  11. Save run_java_test_bat.txt and rename the file as run_java_test.bat

  12. Edit file create_attachment.java in a text editor.

  13. Adjust the following lines based on your SDM instance:
    Line 89:  String username = "ServiceDesk";
    Line 90:  String password = "ServiceDesk";

    Note:  The above should be an SDM user with the Admin Access Type and have no security restrictions introduced by any data partitioning or Function Access configs.

  14. Save the create_attachment.java file.

  15. Open a command prompt on the SDM Server and cd to the C:\java-cxf-sample directory

  16. Run the run_java_test.bat script.  

The following is a sample output indicating a successful run, where Request case 50 was created, and file test_upload_file.txt is attached to the ticket under the default doc repository.

C:\java-cxf-sample>run_java_test.bat

Generating the CA Service Desk Web Services stub files with WSDL2Java


Compiling the CA Service Desk Web Services stub files

error: no source files

Compiling create_attachment.java

warning: Implicitly compiled files were not subject to annotation processing.
  Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
1 warning

Running create_attachment

Mar 05, 2026 9:27:54 PM org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://www.ca.com/UnicenterServicePlus/ServiceDesk}USD_WebService from WSDL: http://localhost:8080/cxf/services/USD_WebService?wsdl

SID: 2080203109
Handle for 'ServiceDesk' is: cnt:XXXX

Creating a Request...
Created Request: 50, Handle: cr:400001

Successfully uploaded the file to the Request, attachment handle: attmnt:400053

C:\java-cxf-sample>

Additional Information

The above instructions and the associated sample code is provided as-is.  Support is not permitted to assist in modifying the above code to provide further functionality.

There is an Axis SOAP equivalent of the create_attachment.java file located in NX_ROOT\samples\sdk\websvc\java\test3_attachments, which can be used to compare the two implementations of SOAP web services, in conjunction with existing documentation for CXF Migration for CA SDM.  Please be aware that Axis Web Services has been deprecated as of June 30, 2025. 

For SDM 17.4 RU5 and above, Axis web services is removed entirely.  The Axis samples may not be available after this RU release.

Ideally, the SDM Server should be a non-production instance without customisations or changes introduced.  This is due to the sample code having been written for a baseline instance of Service Desk and will not have awareness of any customisations that were introduced, such as additional required fields when creating a ticket, or the default document repository being disabled.  It is also not possible to run the above sample code remotely from the SDM Server as the code requires access to certain jar files that exist in the SDM install itself.

The version of CXF binary distributable needed to run the java samples should be 3.6.x.  Later versions of Apache CXF, from 4.x onward, lack support for the Java implementation certified for Service Desk, and also lack certain javax packages that are needed to compile the java samples successfully.  These include javax.activation, javax.jws.soap, and javax.xml.ws.  

Attempting to compile the java samples in such cases (later Java implementations or Apache CXF binaries) may result in compilation errors such as:

CreateAttachment.java:111: error: package javax.activation does not exist