轴:类路径需要类路径规范

时间:2019-12-24 22:13:50

标签: java wsdl classpath axis

现在在这里-我正在尝试在远程ubuntu终端中执行WSDL文件。我已经安装了Java,Axis和ant。我还指定了classpath和CLASSPATH(不确定是否大小写)。但是当我使用以下命令运行它时:

$AXIS2_HOME/bin/wsdl2java.sh -uri ShippingService.wsdl -p pws.client.ShippingService.wsdl -d adb -s

我收到此错误:

 Using AXIS2_HOME: /opt/axis2
 Using JAVA_HOME:  /usr/lib/jvm/jdk-13.0.1
Error: -classpath requires class path specification

AXIS2_HOME=/opt/axis2是在/ etc / environment中定义的;就像JAVA_HOME一样。

说明指定使用axis2-1.4.1,我使用的是最新版本的axis2-1.7.9。较旧的版本在其类路径规范annogen-0.1.0.jar中具有此文件,较新的axis2则没有。这可能是个问题吗?

这是Readme.txt(仅适用于Windows XP):

Requires:
Basic understanding of Web Services with Java
Valid Development/Production Key and Password
Java SE Development Kit (JDK 6 Update 16)
AXIS2 from Apache
Ant from Apache

This example covers the creation of a proper SOAP Client to communicate with the Shipping Web Services.  The solution file was built on a Windows XP system using the Java Development Kit and AXIS2.  The generated sample stub files are located in folder ShippingServiceStub based on this system that generated them.  You can gather the pre-compiled stubs by making sure the Stub class files are in your classpath, or you can generate the stubs on your own following all the steps below.

To Complete:
1. Download Shipping Service 2.0 WSDL File from Eship Web Services site (Login Required)
    a) https://eship.purolator.com/SITE/en/resourcecentre/samplecode.aspx
    Note: In this sample the file has been unzipped to C:\EWSSample\ShippingService-Create directory.  There should now be ShippingService.wsdl in the directory C:\EWSSample\ShippingService-Create\Development.  This is the file we will concentrate on in the next step.

2. Execute WSDL2JAVA to build the stub files (Run this in the C:\EWSSample\ShippingService-Create\Development directory)
    a) Example for all WSDLs from Eship Web Services site
        %AXIS2_HOME%\bin\wsdl2java -uri WSName.wsdl -p pws.client.WSName -d adb -s
        where:
            WSName is the name of the web service, for example: ShippingService
            AXIS2_HOME is environment variable pointing to your Axis2 installation, for example C:\axis2\axis2-1.4.1
            -d adb means that provided samples use Axis Data Binding. It generates one stub class per web service which extends org.apache.axis2.client.Stub.
    b) Our current example
        C:\AXIS2\axis2-1.4.1\bin\wsdl2java -uri ShippingService.wsdl -p pws.client.ShippingService -d adb -s
    Note: If you receive an error 'The JAVA_HOME environment variable is not defined' refer to Installation and Environment Notes file.
    Note: If you receive an error 'The AXIS2_HOME environment variable is not defined' refer to Installation and Environment Notes file.
    Response received:

        Using AXIS2_HOME:   C:\AXIS2\axis2-1.4.1
        Using JAVA_HOME:    C:\Program Files\Java\jdk1.6.0_16
        Retrieving document at 'ShippingService.wsdl'.
    What happened? build.xml was created in local directory.  'src\pws\client\ShippingService' directory created with ShippingServiceCallbackHandler.java, ShippingServiceContract_Consolidate_ValidationFaultFault_FaultMessage.java, ShippingServiceContract_CreateShipment_ValidationFaultFault_FaultMessage, ShippingServiceContract_ValidateShipment_ValidationFaultFault_FaultMessage, ShippingServiceContract_VoidShipment_ValidationFaultFault_FaultMessage and ShippingServiceStub java files created.


3. Download Shipping Service 2.0 Create java sample code and extract ShipmentClientCreate.java to C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService directory.
4. Edit the file and modify the following code
    a) Define the Production (or development) Key and Password
    b) Define your Purolator Account Number ( Note the Test Account Number is 9999999999 )
    c) Define your Postal Code.  Make sure the sending postal code is the one you registered with when receiving the Development Key and Password.


5. Run ant to compile.
    a) Type 'C:\ANT\apache-ant-1.7.1\bin\ant' from the C:\EWSSample\ShippingService-Create\Development directory.

    Response received:
        Buildfile: build.xml

        init:
            [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build
            [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\classes
                [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\lib

        pre.compile.test:
             [echo] Stax Availability= true
             [echo] Axis2 Availability= true

        compile.src:
            [javac] Compiling 5 source files to C:\EWSSample\ShippingService-Create\Development\build\classes
            [javac] Note: C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
            [javac] Note: Recompile with -Xlint:unchecked for details.

        jar.client:
              [jar] Building jar: C:\EWSSample\ShippingService-Create\Development\build\lib\ShippingService-test-client.jar

        BUILD SUCCESSFUL
        Total time: 13 seconds

    b) Type 'C:\ANT\apache-ant-1.7.1\bin\ant' from the C:\EWSSample\ShippingService-Create\Development directory.

    Response received:
        Buildfile: build.xml

        init:
            [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build
            [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\classes
            [mkdir] Created dir: C:\EWSSample\ShippingService-Create\Development\build\lib

        pre.compile.test:
             [echo] Stax Availability= true
             [echo] Axis2 Availability= true

        compile.src:
            [javac] Compiling 4 source files to C:\EWSSample\ShippingService-Create\Development\build\classes
            [javac] C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java:34: error: incompatible types: java.lang.String cannot be converted to pws.client.ShippingService.ShippingServiceStub.String
            [javac]             return Long.toString(System.currentTimeMillis()) + "_" + counter;
            [javac]                                                                    ^
            [javac] Note: C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
            [javac] Note: Recompile with -Xlint:unchecked for details.
            [javac] 1 error

        BUILD FAILED
        C:\EWSSample\ShippingService-Create\Development\build.xml:43: Compile failed; see the compiler error output for details.

        Total time: 4 seconds

        In case you see this error, update C:\EWSSample\ShippingService-Create\Development\src\pws\client\ShippingService\ShippingServiceStub.java by changing method signature of getUniqueSuffix to
        private static synchronized java.lang.String getUniqueSuffix(){



6. Navigate to the C:\EWSSample\ShippingService-Create\Development\src\ directory and compile the client code by running the following
    a) javac pws\client\ShippingService\ShipmentClientCreate.java

    Possible Error 1: 'javac' is not recognized as an internal or external command, operable program or batch file.
    Resolution 1: You need to add the Java path to the PATH Environment Variable.  %JAVA_HOME%\bin.  Refer to Installation and Environment Notes file for additional information.

    Possible Error 2: package org.apache.axis2 does not exist            throws org.apache.axis2.AxisFault
    Resolution 2: Classpath variable needs to be set.  Refer to Installation and Environment Notes file for additional information.

    Response Received:
        C:\EWSSample\ShippingService-Create\Development\src>javac pws\client\ShippingService\ShipmentClientCreate.java
            Note: .\pws\client\ShippingService\ShippingServiceStub.java uses unchecked or unsafe operations.
            Note: Recompile with -Xlint:unchecked for details.


7. Running the code after valid compile above.
    a) C:\EWSSample\ShippingService-Create\Development\src>java pws.client.ShippingService.ShipmentClientCreate

    Possible Error 1: 
        WARNING:
        log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
        log4j:WARN Please initialize the log4j system properly.
    Resolution 1: http://logging.apache.org/log4j/1.2/manual.html.  Refer to Installation and Environment Notes file for additional information.



    Possible Error 2: 
        [main] INFO  org.apache.axis2.transport.http.HTTPSender  - Unable to sendViaPost to url[https://devwebservices.purolator.com/EWS/V2/Shipping/ShippingService.asmx]
        org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
    Resolution 2: Make sure you are using your Development key and Password when connecting to the devwebservices instance.  

    Possible Error 3:
        [main] INFO  org.apache.commons.httpclient.HttpMethodDirector  - No credentials available for BASIC 'Purolator'@devwebservices.purolator.com:
    Resolution 3:
        Make sure code has import procedures:
            import org.apache.axis2.client.Options;
            import org.apache.axis2.transport.http.HTTPConstants;
            import org.apache.axis2.transport.http.HttpTransportProperties;
        Try the alternate way to send in credentials to web service.  Make sure you remark the other credentials that you tried.
            Options options = stub._getServiceClient().getOptions();
                HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
                    auth.setUsername("your key here");
            auth.setPassword("your password here"); 
                    options.setProperty(HTTPConstants.AUTHENTICATE,auth);

    Response Received:

以下是设置说明(仅适用于Windows XP):

Applications to Install:
Java SE Development Kit (JDK 6 Update 16)
AXIS2 from Apache
Ant from Apache

This example covers the creation of a proper SOAP Client to communicate with the Shipping Web Services.  The solution file was built on a Windows XP system using the Java Development Kit and AXIS2.

Installation Instructions for the Environment:


1. Download and install the Java Development Kit
    a) In this document Java SE Development Kit 6 Update 16 was downloaded an installed
    b) Location: http://java.sun.com/javase/downloads/index.jsp
    c) run jdk-6u16-windows-i586.exe  (Extracts Installation files)
    d) Installed to C:\Program Files\Java\jdk1.6.0_16

2. Download and unpack AXIS 2 Standard Binary Distribution version 1.4.1
    a) Location: http://ws.apache.org/axis2/download/1_4_1/download.cgi
    b) Unzip to directory (C:\AXIS2\axis2-1.4.1) 
        Make sure you add JAVA_HOME environment variable pointing to your Java engine root folder (C:\Program Files\Java\jdk1.6.0_16). 
            This can be completed by right clicking My Computer.  Select Properties.  Select Advanced, select Environment variables.  Select 'New' of JAVA_HOME is not listed under System Variables.
            In our example C:\Program Files\Java\jdk1.6.0_16 
        Make sure you add AXIS2_HOME environment variable pointing to your Axis engine root folder (C:\AXIS2\axis2-1.4.1). 
            This can be completed by right clicking My Computer.  Select Properties.  Select Advanced, select Environment variables.  Select 'New' of AXIS_HOME is not listed under System Variables.
            In our example C:\AXIS2\axis2-1.4.1

        Use the online tutorial from Apache for non Java programmers.
    Note: Java sample code uses web service client stubs created with Wsdl2Java utility from Apache Axis2 Web services engine.

3. Download and unpack Apache Ant (1.7.1)
    a) Location: http://ant.apache.org/bindownload.cgi
    b) Unzip to directory (C:\Ant\apache-ant-1.7.1)
    Note: Apache Ant is a Java-based build tool. 

4. Set the Classpath for the jar files that are included in the AXIS directory.  
    a) run the following from command line
        set classpath=C:\AXIS2\axis2-1.4.1\lib\activation-1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\annogen-0.1.0.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-api-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-dom-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axiom-impl-1.2.7.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-adb-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-adb-codegen-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-ant-plugin-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-clustering-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-codegen-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-corba-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-fastinfoset-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-java2wsdl-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxbri-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxws-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jaxws-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jibx-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-json-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-jws-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-kernel-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-metadata-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-mtompolicy-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-saaj-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-saaj-api-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-spring-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\axis2-xmlbeans-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\backport-util-concurrent-3.1.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-codec-1.3.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-fileupload-1.2.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-httpclient-3.1.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-io-1.4.jar;
C:\AXIS2\axis2-1.4.1\lib\commons-logging-1.1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\geronimo-annotation_1.0_spec-1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\geronimo-stax-api_1.0_spec-1.0.1.jar;
C:\AXIS2\axis2-1.4.1\lib\httpcore-4.0-beta1.jar;
C:\AXIS2\axis2-1.4.1\lib\httpcore-nio-4.0-beta1.jar;
C:\AXIS2\axis2-1.4.1\lib\jalopy-1.5rc3.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-api-2.1.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-impl-2.1.6.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxb-xjc-2.1.6.jar;
C:\AXIS2\axis2-1.4.1\lib\jaxen-1.1.1.jar;
C:\AXIS2\axis2-1.4.1\lib\jettison-1.0-RC2.jar;
C:\AXIS2\axis2-1.4.1\lib\jibx-bind-1.1.5.jar;
C:\AXIS2\axis2-1.4.1\lib\jibx-run-1.1.5.jar;
C:\AXIS2\axis2-1.4.1\lib\log4j-1.2.15.jar;
C:\AXIS2\axis2-1.4.1\lib\mail-1.4.jar;
C:\AXIS2\axis2-1.4.1\lib\mex-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\neethi-2.0.4.jar;
C:\AXIS2\axis2-1.4.1\lib\soapmonitor-1.4.1.jar;
C:\AXIS2\axis2-1.4.1\lib\woden-api-1.0M8.jar;
C:\AXIS2\axis2-1.4.1\lib\woden-impl-dom-1.0M8.jar;
C:\AXIS2\axis2-1.4.1\lib\wsdl4j-1.6.2.jar;
C:\AXIS2\axis2-1.4.1\lib\wstx-asl-3.2.4.jar;
C:\AXIS2\axis2-1.4.1\lib\xalan-2.7.0.jar;
C:\AXIS2\axis2-1.4.1\lib\xercesImpl-2.8.1.jar;
C:\AXIS2\axis2-1.4.1\lib\xml-apis-1.3.04.jar;
C:\AXIS2\axis2-1.4.1\lib\xml-resolver-1.2.jar;
C:\AXIS2\axis2-1.4.1\lib\xmlbeans-2.3.0.jar;
C:\AXIS2\axis2-1.4.1\lib\XmlSchema-1.4.2.jar;


5. Set up the file log4j.properties which displays additional information when running code in command line.
    a) Location of Information: http://logging.apache.org/log4j/1.2/manual.html
    b) Create File named: 'log4j.properties' in C:\EWSSample\ShippingService-Create\Development\src directory with the following information.
        # Set root logger level to DEBUG and its only appender to A1.
        log4j.rootLogger=DEBUG, A1

        # A1 is set to be a ConsoleAppender.
        log4j.appender.A1=org.apache.log4j.ConsoleAppender

        # A1 uses PatternLayout.
        log4j.appender.A1.layout=org.apache.log4j.PatternLayout
        log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

请协助。干杯!

0 个答案:

没有答案