【问题标题】:Exception in thread "main" org.apache.axis2.AxisFault: Please implement jdl.helloworld.webservices.service.HelloWorldSkeleton#SayHello线程“主”org.apache.axis2.AxisFault 中的异常:请执行 jdl.helloworld.webservices.service.HelloWorldSkeleton#SayHello
【发布时间】:2011-07-07 23:30:44
【问题描述】:

我是网络服务的新手。我正在尝试通过 Axis2 引擎实现示例 wsdl Web 服务。

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

Web 服务的创建没有任何错误。当我通过命令提示符(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

这是jdl\helloworld\webservices\service目录下的HelloWorldServiceSkeleton.java

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>

请帮帮我。

【问题讨论】:

    标签: web-services axis2


    【解决方案1】:

    您是否使用 wsdl2java 从您的 WSDL 生成 Java 类? wsdl2java 会为您生成一个骨架服务类,它会生成一个 services.xml 文件,该文件表示使用骨架类作为服务类。自动生成的骨架会针对它处理的任何 Web 服务调用抛出带有该消息的 AxisFault。看来 Axis2 正在使用这个骨架类作为服务类,而不是您的服务类。

    通常,您将编写一个扩展骨架类(或实现骨架接口)的服务类。打包服务时,应修改 services.xml 文件,使其将您的类指定为服务类,而不是自动生成的骨架类。

    【讨论】:

    • 感谢 kenster,我没有使用 wsdl2java 文件。而且我在一天的时间后得到了结果。我尝试了另一个与我在上面尝试的示例相同的示例。我想在这里我在 HelloWorld.wsdl 文件中犯了错误。无论如何,非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    相关资源
    最近更新 更多