Исключение в потоке "main" org.apache.axis2.AxisFault: Пожалуйста, реализуйте jdl.helloworld.webservices.service.HelloWorldSkeleton # SayHello - PullRequest
0 голосов
/ 03 марта 2011

Я новичок в веб-сервисе. я пытаюсь реализовать пример веб-службы wsdl через движок Axis2.

 Versions: Axis2 - > axis2-1.1.1, Ant - > apache-ant-1.8.2

веб-сервис создан без каких-либо ошибок. при тестировании через командную строку (Ant Test) получаю сообщение об ошибке типа

    [java] Exception in thread "main" org.apache.axis2.AxisFault: Please implem
ent jdl.helloworld.webservices.service.HelloWorldSkeleton#SayHello
     [java]     at org.apache.axis2.description.OutInAxisOperationClient.send(Ou
tInAxisOperation.java:271)
     [java]     at org.apache.axis2.description.OutInAxisOperationClient.execute
(OutInAxisOperation.java:202)
     [java]     at jdl.helloworld.webservices.service.HelloWorldStub.SayHello(Un
known Source)
     [java]     at jdl.helloworld.webservices.client.Client.main(Unknown Source)

     [java] Java Result: 1

Это HelloWorldServiceSkeleton.java в каталоге jdl \ helloworld \ webservices \ service

package jdl.helloworld.webservices.service;

import org.apache.ws.axis2.helloworld.SayHello;
import org.apache.ws.axis2.helloworld.SayHelloResponse;
import org.apache.ws.axis2.helloworld.PrintValues;

public class HelloWorldServiceSkeleton 
{
    public org.apache.ws.axis2.helloworld.SayHelloResponse SayHello(org.apache.ws.axis2.helloworld.SayHello param0)throws Exception {
        SayHelloResponse sayHelloResponse=new SayHelloResponse();
        try{

            sayHelloResponse.setName(param0.getName());
            System.out.println("Hello World Service called");
        }catch(Exception e){
            System.out.println(" Error Occured : "+e);
        }
        return sayHelloResponse;
    }

    public String PrintValues(org.apache.ws.axis2.helloworld.PrintValues param1){
        return "printvalues";
    }

}

файл Client.java

package jdl.helloworld.webservices.client;

import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import jdl.helloworld.webservices.service.HelloWorldStub;
import jdl.helloworld.webservices.service.HelloWorldStub.SayHello;
import jdl.helloworld.webservices.service.HelloWorldStub.SayHelloResponse;
import jdl.helloworld.webservices.service.HelloWorldStub.PrintValues;
import jdl.helloworld.webservices.service.HelloWorldStub.PrintValuesResponse;

public class Client 
{
    public static void main(String[] args)throws Exception 
    {               
        System.out.println("-- Inside Client --");
        ConfigurationContext configurationContext=ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:\\axis2-1.1.1\\repository", "C:\\axis2-1.1.1\\conf\\axis2.xml");
        HelloWorldStub helloWorldStub=new HelloWorldStub(configurationContext,"http://localhost:8080/axis2/services/HelloWorld");
        System.out.println(" --> sayHello Begin");
        SayHello sayHello=new SayHello();
        sayHello.setName("user");       
        SayHelloResponse sayHelloResponse=helloWorldStub.SayHello(sayHello);            
        System.out.println(" --> sayHello Response : "+sayHelloResponse.getName());         
    }
}

файл HelloWorld.wsdl

<wsdl:definitions name="HelloWorld"
    xmlns:tns="http://ws.apache.org/axis2/HelloWorld/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    targetNamespace="http://ws.apache.org/axis2/HelloWorld/">
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"
            targetNamespace="http://ws.apache.org/axis2/HelloWorld/">
            <xsd:element name="SayHello">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="0" name="Name" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>       
            <xsd:element name="SayHelloResponse">
                <xsd:complexType>        
                    <xsd:sequence>
                        <xsd:element name="Name" minOccurs="0" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="PrintValues">
                <xsd:complexType>        
                    <xsd:sequence>
                        <xsd:element name="Name" minOccurs="0" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="PrintValuesResponse">
                <xsd:complexType>        
                    <xsd:sequence>
                        <xsd:element name="Name" minOccurs="0" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="SayHelloSoapIn">
        <wsdl:part name="parameters" element="tns:SayHello"/>
    </wsdl:message>  
    <wsdl:message name="SayHelloSoapOut">
        <wsdl:part name="parameters" element="tns:SayHelloResponse"/>
    </wsdl:message>

    <wsdl:message name="PrintValuesSoapOut">
        <wsdl:part name="parameters" element="tns:PrintValues"/>
    </wsdl:message>
    <wsdl:message name="PrintValuesSoapOut">
        <wsdl:part name="parameters" element="tns:PrintValuesResponse"/>
    </wsdl:message>

    <wsdl:portType name="HelloWorldSoap"> 
        <wsdl:operation name="SayHello">
            <wsdl:input message="tns:SayHelloSoapIn"/>
            <wsdl:output message="tns:SayHelloSoapOut"/>
        </wsdl:operation>
        <wsdl:operation name="PrintValues">
            <wsdl:input message="tns:PrintValuesSoapIn"/>
            <wsdl:output message="tns:PrintValuesSoapOut"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloWorldSoap" type="tns:HelloWorldSoap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="SayHello">
            <soap:operation soapAction="http://localhost:8080/axis2/HelloWorld/SayHello" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>        
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="PrintValues">
            <soap:operation soapAction="http://localhost:8080/axis2/HelloWorld/PrintValues" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>        
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloWorld">
        <wsdl:port name="HelloWorldSoap"
            binding="tns:HelloWorldSoap">
            <soap:address location="http://localhost:8080/axis2/services/HelloWorld" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Пожалуйста, помогите мне.

1 Ответ

0 голосов
/ 10 марта 2011

Использовали ли вы wsdl2java для генерации классов Java из вашего WSDL?wsdl2java генерирует для вас класс сервиса скелета и генерирует файл services.xml, в котором говорится, что в качестве класса сервиса нужно использовать класс скелета.Автоматически сгенерированный скелет генерирует AxisFault с этим сообщением для любого вызова веб-службы, который он обрабатывает.Похоже, что Axis2 использует этот класс скелета в качестве класса обслуживания вместо вашего класса обслуживания.

Обычно вы пишете класс обслуживания, который расширяет класс скелета (или реализует интерфейс скелета).Когда вы упаковываете службу, вы должны изменить файл services.xml так, чтобы он указывал ваш класс в качестве класса службы вместо автоматически сгенерированного каркасного класса.

...