自己写的HelloWorldService的接口和实现如下:
package hpx.example.xfire.finaltest;public interface HelloWorldService { public String hello(String name);
}// ------------------------------------------
package hpx.example.xfire.finaltest;public class HelloWorldServiceImpl implements HelloWorldService { public String hello(String name) { if (name == null) {
return "Hello Guest";
}
return "Hello " + name;
}}
// ------------------------------------------
然后写了相应的services.xml,
在http://localhost:8888/XFireFinalTest/services/HelloService?wsdl路经下保存了wsdl文件,
并编写了ant的部署,最后根据wsdl,使用ant create_code生成了很多代码,生成的services.xml把我以前写的给覆盖了。
其中wsgen生成的的代码如下(先只写两个吧):
package hpx.example.xfire.helloworld.client;import javax.jws.WebService;@WebService(serviceName = "HelloService", targetNamespace = "http://finaltest.xfire.example.hpx", endpointInterface = "hpx.example.xfire.helloworld.client.HelloServicePortType")
public class HelloServiceImpl
    implements HelloServicePortType
{
    public String hello(String in0) {
        throw new UnsupportedOperationException();
    }}// ----------------------------------------------
package hpx.example.xfire.helloworld.client;import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;@WebService(name = "HelloServicePortType", targetNamespace = "http://finaltest.xfire.example.hpx")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public interface HelloServicePortType {
    @WebMethod(operationName = "hello", action = "")
    @WebResult(name = "out", targetNamespace = "http://finaltest.xfire.example.hpx")
    public String hello(
        @WebParam(name = "in0", targetNamespace = "http://finaltest.xfire.example.hpx")
        String in0);}//-----------------------------------------------------请高手有时间帮忙看看吧!不胜感激

解决方案 »

  1.   

    其实很简单的:
    1)写一个给外部调用的接口 就是 HelloWorldService.java, 从你上面的来看很好
    2)接下来就可以写一个实现类了,就是HelloWorldServiceImpl.java,这个看来也是没有问题的
    3)就是编写service.xml了,从你这个例子来看只要象下面的这样就可以了
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://xfire.codehaus.org/config/1.0">
        <service>
            <name>helloWorld</name>
            <serviceClass>hpx.example.xfire.finaltest.HelloWorldService </serviceClass>
            <implementationClass>hpx.example.xfire.finaltest.HelloWorldServiceImpl</implementationClass>
            <scope>application</scope>
        </service>
    </beans>
    4)web.xml这个如果你是在Eclipse下开发的会自动生成相关的配置文件,如
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <servlet>
        <servlet-name>XFireServlet</servlet-name>
        <servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>XFireServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
      </servlet-mapping>
      
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>5)你还要写一个调用的前台程序,url为http://localhost:8080/helloWorld/services/helloWorld.wsdl
    当然你发布后,看看 http://localhost:8080/helloWorld/services/helloWorld.wsdl 是不是正确,还有把相应的包给加上,最好在Eclipse中建立一个Service项目,把需要的包全部勾上,这样可以保证不会缺少什么.jar6)为汶川默哀,为汶川加油,为中国加油
      

  2.   

    添加commons-codec-1.3.jar、commons-httpclient-3.0.jar、commons-logging-1.0.4.jar这三个JAR文件到项目里试试