日期:2014-05-17  浏览次数:21201 次

xfire java.lang.IllegalStateException: Could not initialize Service
大家好!
我在网上下载了一个xfire 客户端消费的实例,运行时报错:
Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service.
at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:77)
at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
at javax.xml.ws.Service.<init>(Service.java:56)
at test.jax.HelloWorldSimple.<init>(HelloWorldSimple.java:54)
at test.xfireclient.ClientMain.main(ClientMain.java:25)
Caused by: java.lang.NoSuchMethodException: test.jax.HelloWorldSimple.getPortClassMap()
at java.lang.Class.getMethod(Class.java:1605)
at org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:60)
... 4 more

客户端代码为:
package test.xfireclient;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.PortInfo;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;

import test.jax.HelloWorldSimple;
public class ClientMain {

@SuppressWarnings("unchecked")  
    public static void main(String[] args) {  
        HelloWorldSimple simple = new HelloWorldSimple();  
  
        simple.setHandlerResolver(new HandlerResolver() {  
            public List<Handler> getHandlerChain(PortInfo portInfo) {  
                List<Handler> list = new ArrayList<Handler>();  
                list.add(new MySOAPHandler());  
                return list;  
            }  
        });  
        test.jax.HelloWorldSimplePortType port = simple.getHelloWorldSimpleHttpPort();  
        System.out.println(port.sayHello("cat1"));  
    }
static class MySOAPHandler implements SOAPHandler<SOAPMessageContext> {