2017-08-22 11 views
0

軸ClassNotFoundExceptionが:は、私は枢軸Webサービスでカスタムオブジェクトを返すようにしようとすると、私は次のエラーを取得しています

aug 22, 2017 12:11:52 PM org.apache.axis.deployment.wsdd.WSDDService deployTypeMapping 
SEVERE: Unable to deploy typemapping: {http://server}Case 
java.lang.ClassNotFoundException: server._case 
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1269) 
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104) 
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187) 

私のケースクラスを見つけることができないWebサービスのように思えるが、それは、WSDLで定義されています。

これは私のコードです: ケース:

package server; 

import java.io.Serializable; 

public class Case implements Serializable { 

    private static final long serialVersionUID = -1549174508068625157L; 
    private String id; 

    public Case() { 

    } 

    public Case(String id) { 
     this.id = id; 
    } 

    public String getId() { 
     return id; 
    } 

    public void setId(String id) { 
     this.id = id; 
    } 

} 

CaseServiceImpl:

package server; 

public class CaseServiceImpl implements CaseService { 

    //This one works 
    @Override 
    public String hello(String message) { 
     return message; 
    } 

    //This one doesn't show up 
    @Override 
    public Case test() { 
     return new Case("TR-1"); 
    } 

} 

CaseServiceImpl.wsdl(自動生成):

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions targetNamespace="http://server" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://server" xmlns:intf="http://server" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<!--WSDL created by Apache Axis version: 1.4 
Built on Apr 22, 2006 (06:55:48 PDT)--> 
<wsdl:types> 
    <schema elementFormDefault="qualified" targetNamespace="http://server" xmlns="http://www.w3.org/2001/XMLSchema"> 
    <element name="test"> 
    <complexType/> 
    </element> 
    <element name="testResponse"> 
    <complexType> 
    <sequence> 
     <element name="testReturn" type="impl:Case"/> 
    </sequence> 
    </complexType> 
    </element> 
    <complexType name="Case"> 
    <sequence> 
    <element name="id" nillable="true" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    <element name="hello"> 
    <complexType> 
    <sequence> 
     <element name="message" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    </element> 
    <element name="helloResponse"> 
    <complexType> 
    <sequence> 
     <element name="helloReturn" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    </element> 
    </schema> 
</wsdl:types> 

    <wsdl:message name="testResponse"> 

     <wsdl:part element="impl:testResponse" name="parameters"> 

     </wsdl:part> 

    </wsdl:message> 

    <wsdl:message name="helloResponse"> 

     <wsdl:part element="impl:helloResponse" name="parameters"> 

     </wsdl:part> 

    </wsdl:message> 

    <wsdl:message name="helloRequest"> 

     <wsdl:part element="impl:hello" name="parameters"> 

     </wsdl:part> 

    </wsdl:message> 

    <wsdl:message name="testRequest"> 

     <wsdl:part element="impl:test" name="parameters"> 

     </wsdl:part> 

    </wsdl:message> 

    <wsdl:portType name="CaseServiceImpl"> 

     <wsdl:operation name="test"> 

     <wsdl:input message="impl:testRequest" name="testRequest"> 

     </wsdl:input> 

     <wsdl:output message="impl:testResponse" name="testResponse"> 

     </wsdl:output> 

     </wsdl:operation> 

     <wsdl:operation name="hello"> 

     <wsdl:input message="impl:helloRequest" name="helloRequest"> 

     </wsdl:input> 

     <wsdl:output message="impl:helloResponse" name="helloResponse"> 

     </wsdl:output> 

     </wsdl:operation> 

    </wsdl:portType> 

    <wsdl:binding name="CaseServiceImplSoapBinding" type="impl:CaseServiceImpl"> 

     <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 

     <wsdl:operation name="test"> 

     <wsdlsoap:operation soapAction=""/> 

     <wsdl:input name="testRequest"> 

      <wsdlsoap:body use="literal"/> 

     </wsdl:input> 

     <wsdl:output name="testResponse"> 

      <wsdlsoap:body use="literal"/> 

     </wsdl:output> 

     </wsdl:operation> 

     <wsdl:operation name="hello"> 

     <wsdlsoap:operation soapAction=""/> 

     <wsdl:input name="helloRequest"> 

      <wsdlsoap:body use="literal"/> 

     </wsdl:input> 

     <wsdl:output name="helloResponse"> 

      <wsdlsoap:body use="literal"/> 

     </wsdl:output> 

     </wsdl:operation> 

    </wsdl:binding> 

    <wsdl:service name="CaseServiceImplService"> 

     <wsdl:port binding="impl:CaseServiceImplSoapBinding" name="CaseServiceImpl"> 

     <wsdlsoap:address location="http://localhost:8080/MORPOC_SOAP/services/CaseServiceImpl"/> 

     </wsdl:port> 

    </wsdl:service> 

</wsdl:definitions> 

私が行方不明ですように私は感じます私は何かを知りません。誰かが私を正しい方向に向けることができますか?

答えて

-1

caseが予約されているため、ある時点で大文字小文字を区別しているので、私のクラスには名前ケースを使用できません。クラスの名前を変更した後、それは動作します。

+0

なぜこれがdownvotedでしたか? –

0

あなたの問題の解決策は既に見つかっているようですが、潜在的な読者のための詳細な手順を投稿します。うまくいけば、それはあなたの問題がエンティティの名前ではないことを確信していないので、あなたの解決策を改善するのにも役立ちます。

前提条件

  1. Ant
  2. Axis2を設置したがダウンロードされ、AXIS_HOME環境変数は、環境変数で セット
  3. すべてのアプリケーションは、軸を配備するために利用可能である適切でした。私の場合は、Tomcat Apache Tomcat/7.0.41を使用しました。軸を展開するには、以前にダウンロードした軸フォルダをTOMCAT_HOME\webappsフォルダに追加するだけです。

私は同じBeanとサービス実装を使用しています。だから、:

Case.java

package server; 

import java.io.Serializable; 

public class Case implements Serializable { 

    private static final long serialVersionUID = -1549174508068625157L; 
    private String id; 

    public Case() { 
    } 

    public Case(String id) { 
     this.id = id; 
    } 

    public String getId() { 
     return id; 
    } 

    public void setId(String id) { 
     this.id = id; 
    } 
} 

CaseService.java

package server; 

interface CaseService { 
    String hello(String message); 
    Case test(); 
} 

CaseServiceImpl.java

package server; 

public class CaseServiceImpl implements CaseService { 
    //This one works 
    @Override 
    public String hello(String message) { 
     return message; 
    } 

    //This one doesn't show up 
    @Override 
    public Case test() { 
     return new Case("TR-1"); 
    } 
} 

このインフラストラクチャを作成すると、サービスインタフェースに基づいてwsdlを生成できます。コンパイルされたファイルが格納されているフォルダより1つ上の階層に移動します(Case.classCaseService.classCaseServiceImpl.class)。私たちの場合、これは次のとおりです。コマンド以下 enter image description here

し、実行:

%AXIS2_HOME%\bin\java2wsdl.bat -cp . -cn server.CaseService -of CaseService.wsdl 

結果は以下のことになります。 enter image description here

また、新しいファイルCaseService.wsdlが作成されます。

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://server" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://server/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://server"> 
    <wsdl:types> 
     <xs:schema xmlns:ax22="http://server/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://server"> 
      <xs:import namespace="http://server/xsd"/> 
      <xs:element name="test"> 
       <xs:complexType> 
        <xs:sequence/> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="testResponse"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element minOccurs="0" name="return" nillable="true" type="ax22:Case"/> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="hello"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element minOccurs="0" name="args0" nillable="true" type="xs:string"/> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="helloResponse"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
     </xs:schema> 
     <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://server/xsd"> 
      <xs:complexType name="Case"> 
       <xs:sequence> 
        <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="testRequest"> 
     <wsdl:part name="parameters" element="ns:test"/> 
    </wsdl:message> 
    <wsdl:message name="testResponse"> 
     <wsdl:part name="parameters" element="ns:testResponse"/> 
    </wsdl:message> 
    <wsdl:message name="helloRequest"> 
     <wsdl:part name="parameters" element="ns:hello"/> 
    </wsdl:message> 
    <wsdl:message name="helloResponse"> 
     <wsdl:part name="parameters" element="ns:helloResponse"/> 
    </wsdl:message> 
    <wsdl:portType name="CaseServicePortType"> 
     <wsdl:operation name="test"> 
      <wsdl:input message="ns:testRequest" wsaw:Action="urn:test"/> 
      <wsdl:output message="ns:testResponse" wsaw:Action="urn:testResponse"/> 
     </wsdl:operation> 
     <wsdl:operation name="hello"> 
      <wsdl:input message="ns:helloRequest" wsaw:Action="urn:hello"/> 
      <wsdl:output message="ns:helloResponse" wsaw:Action="urn:helloResponse"/> 
     </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="CaseServiceSoap11Binding" type="ns:CaseServicePortType"> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     <wsdl:operation name="test"> 
      <soap:operation soapAction="urn:test" style="document"/> 
      <wsdl:input> 
       <soap:body use="literal"/> 
      </wsdl:input> 
      <wsdl:output> 
       <soap:body use="literal"/> 
      </wsdl:output> 
     </wsdl:operation> 
     <wsdl:operation name="hello"> 
      <soap:operation soapAction="urn:hello" style="document"/> 
      <wsdl:input> 
       <soap:body use="literal"/> 
      </wsdl:input> 
      <wsdl:output> 
       <soap:body use="literal"/> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:binding name="CaseServiceSoap12Binding" type="ns:CaseServicePortType"> 
     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     <wsdl:operation name="test"> 
      <soap12:operation soapAction="urn:test" style="document"/> 
      <wsdl:input> 
       <soap12:body use="literal"/> 
      </wsdl:input> 
      <wsdl:output> 
       <soap12:body use="literal"/> 
      </wsdl:output> 
     </wsdl:operation> 
     <wsdl:operation name="hello"> 
      <soap12:operation soapAction="urn:hello" style="document"/> 
      <wsdl:input> 
       <soap12:body use="literal"/> 
      </wsdl:input> 
      <wsdl:output> 
       <soap12:body use="literal"/> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:binding name="CaseServiceHttpBinding" type="ns:CaseServicePortType"> 
     <http:binding verb="POST"/> 
     <wsdl:operation name="test"> 
      <http:operation location="test"/> 
      <wsdl:input> 
       <mime:content type="application/xml" part="parameters"/> 
      </wsdl:input> 
      <wsdl:output> 
       <mime:content type="application/xml" part="parameters"/> 
      </wsdl:output> 
     </wsdl:operation> 
     <wsdl:operation name="hello"> 
      <http:operation location="hello"/> 
      <wsdl:input> 
       <mime:content type="application/xml" part="parameters"/> 
      </wsdl:input> 
      <wsdl:output> 
       <mime:content type="application/xml" part="parameters"/> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="CaseService"> 
     <wsdl:port name="CaseServiceHttpSoap11Endpoint" binding="ns:CaseServiceSoap11Binding"> 
      <soap:address location="http://localhost:8080/axis2/services/CaseService"/> 
     </wsdl:port> 
     <wsdl:port name="CaseServiceHttpSoap12Endpoint" binding="ns:CaseServiceSoap12Binding"> 
      <soap12:address location="http://localhost:8080/axis2/services/CaseService"/> 
     </wsdl:port> 
     <wsdl:port name="CaseServiceHttpEndpoint" binding="ns:CaseServiceHttpBinding"> 
      <http:address location="http://localhost:8080/axis2/services/CaseService"/> 
     </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

これで、WSコンポーネントを生成する準備が整いました。

%AXIS2_HOME%\bin\WSDL2Java -uri CaseService.wsdl -d adb -s -ss -sd -ssi -o service 

結果は次されます:CaseService.wsdlは、以下のコマンドを実行して生成されたフォルダから enter image description here

そして新しいフォルダserviceが生成されます。このコマンドは、WSメソッドを実装するスケルトンも生成します。したがって、CaseServiceSkeleton.javaを開き、hellotestメソッドを実装します。結果は、そのようなものでなければなりません:

package server; 

public class CaseServiceSkeleton implements CaseServiceSkeletonInterface { 
    public HelloResponse hello(Hello hello0) { 
     CaseService caseService = new CaseServiceImpl(); 
     String hello = caseService.hello(hello0.getArgs0()); 

     HelloResponse helloResponse = new HelloResponse(); 
     helloResponse.set_return(hello); 
     return helloResponse; 
    } 

    public TestResponse test(Test test2) { 
     CaseService caseService = new CaseServiceImpl(); 
     Case test = caseService.test(); 
     server.xsd.Case aCase = new server.xsd.Case(); 
     aCase.setId(test.getId()); 
     TestResponse testResponse = new TestResponse(); 
     testResponse.set_return(aCase); 
     return testResponse; 
    } 
} 

あなたはCaseServiceSkeleton.javaが生成された同じフォルダにこれらのファイルをコピーする(ステップ#1中に生成された)CaseServiceCaseServiceImplCaseへの依存性を持っているので。 *.aarファイルを生成する準備ができました。 WS配備に使用されます。新しく生成されたserviceフォルダに移動し、antコマンドを実行します。

ant -buildfile build.xml 

結果は以下のことになります。 enter image description here

そしてbuild\lib\フォルダにはCaseService.aarに作成されます。 何らかの理由でTest.class*.aarファイルに自動的に含まれていなかったため、手動で追加する必要があります。build/classesフォルダのTest.classを新しく生成したCaseService.aarserverフォルダにコピーしてください。すべてのこれらのステップの後CaseService.aar\serverフォルダには、そのようになります。 enter image description here

今あなたが軸に展開することができます - ちょうど軸のWebアプリケーションでWEB-INF\services\にコピーします。アプリケーションサーバーを起動すると、新しいサービスが表示されます。 http://your_host:your_port/axis_application_name/services/listServicesにアクセスしてください。展開が正常に行った場合は、次のページが表示されます: enter image description here

サービス起動

を提供するサービスをinvoceする方法多くの方法があります。ここでは、生成されたクライアントスタブを使用します。クライアントを生成するためのWSDLファイルとフォルダから次のコマンドを使用してください:

%AXIS2_HOME%\bin\WSDL2Java -uri CaseService.wsdl -d adb –o client 

結果は以下のことになります。 enter image description here

このコマンドは二つのファイルとsrcフォルダが生成されます:CaseServiceStub.javaCaseServiceCallbackHandler.java。これらのファイルは、クライアントアプリケーションによって使用されます。 は、今、私たちは、クライアントアプリケーション自体を作成するための準備ができている:

Client.java

package client; 

import org.apache.axis2.AxisFault; 

public class Client { 
    public static void main(String... args) { 
     try { 
      CaseServiceStub stub = new CaseServiceStub("http://localhost:8080/axis/services/CaseService"); 
      invokeHelloMethod(stub); 
      invokeTestMethod(stub); 
     } catch (AxisFault axisFault) { 
      axisFault.printStackTrace(); 
     } 
    } 

    public static void invokeHelloMethod(CaseServiceStub stub) { 
     try { 
      CaseServiceStub.Hello request = new CaseServiceStub.Hello(); 
      request.setArgs0("Hello World"); 

      CaseServiceStub.HelloResponse response = stub.hello(request); 
      System.out.println("Hello method says: " + response.get_return()); 
     } catch (java.rmi.RemoteException e) { 
      e.printStackTrace(); 
     } 
    } 

    public static void invokeTestMethod(CaseServiceStub stub) { 
     try { 
      CaseServiceStub.Test request = new CaseServiceStub.Test(); 
      CaseServiceStub.TestResponse response = stub.test(request); 
      System.out.println("Test method says: " + response.get_return().getId()); 
     } catch (java.rmi.RemoteException e) { 
      e.printStackTrace(); 
     } 
    } 
} 

CaseServiceStubオブジェクトの作成中にWSのURLを変更することを忘れないでください。結果には、このクラスの実行後、次の出力を取得する必要があります:

Hello method says: Hello World 
Test method says: TR-1 

この意志は、人々があなたの例を実行するのに役立ちます希望:)

関連する問題