上一主题: 在 Java 实施 loginServiceManaged

下一主题: impersonate

使用 WSDL2Java 生成 Stub 类

可以为 CA SDM Web 服务生成 Stub 类。

使用 WSDL2Java 生成 stub 类

  1. 打开命令提示符,并导航到“<驱动器>:\program files\CA”目录。

    此时将显示该目录。

  2. 运行 dir/x 命令。

    此时将显示 CA SDM 目录的简略形式。 例如,简称是“SERVIC~1”

  3. 在服务器的所有本地驱动器上搜索 javac.exe。 如果找到该文件,请记下其位置,将来在批处理文件中需要引用它。

    注意:如果找不到 javac.exe,请访问 Http://java.sun.com 并搜索 Java J2SE SDK 以下载。 这可能需要重新启动。

  4. 生成名为 build_wsdl.bat 的批处理文件,并将它放置在以下目录中:
    $NX_ROOT\bopcfg\www\CATALINA_BASE\webapps\axis
    
  5. 为该批处理文件使用以下代码,根据需要更新粗体项:
    @echo off
    ::##################################################################
    ::# Simple bat file to Build Unicenter Service Desk Version 11.0 USD Stub classes
    ::# Use it to create the required USD Unicenter Service Desk Version 11.0 Java Web Services classes
    ::#
    ::#  Usage: build_wsdl
    ::#################################################################
    @REM Update this with the PATH to USD NX_ROOT location
    @SET USD_SHORT_PATH=C:\Progra~1/CA/Servic~1/
    
    @REM Update this with the PATH to the JDK javac.exe compiler 
    @REM(这是此文件的第二部分)
    @SET JAVAC_EXE="C:\j2sdk1.4.2_13\bin\javac.exe"
    @REM Update this to the path to the USD Unicenter Service Desk Version 12.7 NX_ROOT/java/lib location
    @SET USD_TOMCAT=%USD_SHORT_PATH%java/lib
    @SET CP=%USD_TOMCAT%/axis.jar;%USD_TOMCAT%/commons-discovery.jar;%USD_TOMCAT%/commons-logging.jar;%USD_TOMCAT%/jaxrpc.jar;%USD_TOMCAT%/saaj.jar;%USD_TOMCAT%/log4j-1.2.8.jar;%USD_TOMCAT%/xml-apis.jar;%USD_TOMCAT%/xercesImpl.jar;%USD_TOMCAT%/wsdl4j.jar;%USD_TOMCAT%/axis-ant.jar
    @REM Please specify the path to java.exe file below
    @REM You can obtain this by reviewing the NX.env file use the @NX_JRE_INSTALL_DUR 
    @REM variable to derive this info
    @SET JAVA_PATH=C:\Program Files(x86)\CA\SC\JRE\1.6.0_30
    @SET JAVA_EXE="%JAVA_PATH%\bin\java.exe"
    @cd WEB-INF\classes
    %JAVA_EXE% -cp %CP% org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/services/USD_Unicenter Service Desk Version 11.0_WebService?wsdl
    @cd ..\..
    ::##################################################################
    ::# This next section compiles the Service Desk stub code 
    ::# Once complete, you should recycle tomcat with the following 
    ::# commands or by recycling Service Desk:
    ::#       pdm_tomcat_nxd -c STOP
    ::#       pdm_tomcat_nxd -c START
    ::##################################################################
    @SET CP=".\classes;%CP%"
    @SET STUBS_DIR=classes\com\ca\www\UnicenterServicePlus\ServiceDesk
    @cd WEB-INF
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\ArrayOfInt.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\ArrayOfString.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\ListResult.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\USD_WebService.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\USD_WebServiceLocator.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\USD_WebServiceSoap.java
    %JAVAC_EXE% -classpath %CP% -deprecation -d classes %STUBS_DIR%\USD_WebServiceSoapSoapBindingStub.java
    @cd ..
    

    在命令提示符下运行该批处理文件之后,会创建并编译 stub 类。

  6. 重新启动 Tomcat,如下所示: