loyaltyUtopia
2009-07-03 14:35
浏览 218
已采纳

axis2集成Spring服务发布成功,访问时出java.lang.NullPointerException

我集成了Spring的Axis web服务显示发布成功,能看到http://localhost:8080/axisSpring/services/TestSpringHello?wsdl页面,但是写一个类调用这个服务时出错。
我写的调用类是:
[code="java"]package study;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class TestClient {

public static void main(String[] args) throws Exception {


    // 指出service所在URL

    String endpoint = "http://localhost:8080/axisSpring/services/TestSpringHello";

    // 创建一个服务(service)调用(call)

    Service service = new Service();

    Call call = (Call) service.createCall();// 通过service创建call对象

    // 设置service所在URL

    call.setTargetEndpointAddress(new java.net.URL(endpoint));

    // 方法名(processService)与MyService.java方法名保持一致

    call.setOperationName("response");

    // Object 数组封装了参数,参数为"This is Test!",调用processService(String arg)

    String ret = (String) call.invoke(new Object[] { "你好" });

    System.out.println(ret);

}

}
[/code]
[quote]
报的异常为(是在String ret = (String) call.invoke(new Object[] { "你好" });的那行出的错):
[/quote]
[code="java"]
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.NullPointerException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:HYAS-BCC2CBB787

java.lang.NullPointerException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at study.TestClient.main(TestClient.java:37)

[/code]

[quote]
我写的服务类是
[/quote]
[code="java"]
package study;

public class TestSpringHello{

private Test myBean;

public void setMyBean(Test myBean){
    this.myBean = myBean;
}

public String response(String aaa){

    return myBean.echo() + "Christmas" + aaa;
}

}
[/code]

我该这么做才能解决这个问题呢?多谢了。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • liuhong2099 2009-07-04 22:19
    已采纳

    这么长的代码,你还不如自己单步调试 就出来了,看看哪个值为null :oops:

    打赏 评论

相关推荐 更多相似问题