调用报错:
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)调用代码:
Service service = new ObjectServiceFactory().create(ICheckLogin.class);
XFireProxyFactory proxyFactory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String url = "http://10.31.1.240:8080/computation/services.ws";
ICheckLogin login = (ICheckLogin) proxyFactory.create(service, url);
System.out.println(login.myTest());
服务端代码:public String myTest(){
System.out.println("调用....");
FlSysSet flsysSet = sysSetDao.findById(1);
System.out.println(flsysSet.getCname()+" " +flsysSet.getCmemo());
return flsysSet.getCmemo();}

解决方案 »

  1.   


    web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <display-name>xfire_spring</display-name>
     
     <!-- start -->
     <context-param>
      <param-name>contextConfigLocation</param-name>  
     <param-value>classpath:org/codehaus/xfire/spring/xfire.xml,/WEB-INF/applicationContext*.xml</param-value>  
    </context-param>
      <!-- Load Spring ContextServlet -->
     <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener> 
     <servlet>   
         <servlet-name>xfire</servlet-name>   
         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>   
     </servlet> 
     <servlet-mapping>
         <servlet-name>xfire</servlet-name>
         <url-pattern>*.ws</url-pattern>
     </servlet-mapping>
    </web-app>applicationContext-webService.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">  
    <beans>
     <bean id="jiaXFire" class="com.flsoft.cmptImpl.CheckLoginImpl"></bean>
    </beans>xfire-servlet.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
    <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
     <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
      <property name="urlMap">
             <map>
              <entry key="/services.ws">
                  <ref bean="jiaICheck"/>  
                </entry> 
             </map>
         </property>
       </bean> 
       
       <bean id="jiaICheck" parent="webService" class="org.codehaus.xfire.spring.remoting.XFireExporter"> 
         <property name="serviceBean"> 
             <ref bean="jiaXFire"/> 
         </property> 
         <property name="serviceClass"> 
             <value>com.flsoft.cmptService.ICheckLogin</value> 
         </property> 
         <property name="inHandlers" ref="addressingHandler" />
       </bean> 
      <bean id="addressingHandler" class="com.flsoft.util.OutHeaderHandler"/> 
    <!-- <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/>-->
      <!-- webService base -->
       <bean id="webService" class="org.codehaus.xfire.spring.remoting.XFireExporter" abstract="true">
            <property name="serviceFactory">
                <ref bean="xfire.serviceFactory" />
            </property>
            <property name="xfire">
                <ref bean="xfire" />
            </property>
         </bean>
         
    </beans>
      

  2.   


    org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
    空指针异常,你看看这个XFireFault是哪里空了
      

  3.   

     服务端测试:public static void main(String[] args) {
    ApplicationContext context = new FileSystemXmlApplicationContext(
    "/WebRoot/WEB-INF/applicationContext.xml");
    CheckLoginImpl login = (CheckLoginImpl)context.getBean("sysTest");
    System.out.println(login.myTest());
    }测试是有数据的;如果不用hibernate 的方法,调用可以,用hibernate 的方法就不行;执行:FlSysSet flsysSet = sysSetDao.findById(1);
    或是findAll(); 这儿就错了!!
    http://10.31.1.240:8080/computation/services.ws?wsdl  XML文档可以出来希望高手指点一下,郁闷很久了!!