新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     >>计算机科学论坛<<     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> Web服务(Web Services,WS), 语义Web服务(Semantic Web Services, SWS)讨论区: WSDL, SOAP, UDDI, DAML-S, OWL-S, SWSF, SWSL, WSMO, WSML,BPEL, BPEL4WS, WSFL, WS-*,REST, PSL, Pi-calculus(Pi演算), Petri-net,WSRF,
    [返回] 计算机科学论坛W3CHINA.ORG讨论区 - Web新技术讨论『 Web Services & Semantic Web Services 』 → 请教客户端调用web service服务异常! 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 11075 个阅读者  浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 请教客户端调用web service服务异常! 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     sxjida 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:12
      积分:119
      门派:W3CHINA.ORG
      注册:2007/11/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sxjida发送一个短消息 把sxjida加入好友 查看sxjida的个人资料 搜索sxjida在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看sxjida的博客楼主
    发贴心情 请教客户端调用web service服务异常!

    菜鸟初学,请大虾指点啊!
    使用MyEclipse的web services explorer浏览器的WSDL页面直接调用web service服务,
    或者使用axis2自动生成客户端stub类代理TermInfoStub和JUnit Test类TermInfoTest,调用web service服务时
    1、客户端报错空指针异常:
    [ERROR] Exception occurred while trying to invoke service method getTermInfoById
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
    at dataAccess.TermInfo.getTermInfoById(TermInfo.java:450)
    ... 25 more


    2、如果使用axis2自动生成Client端的代理类TermInfoStub和JUnit Test类TermInfoTest,调用web service服务时,(详细代码见3),
    debug跟踪,执行到_operationClient.execute(true);时出现上面的空指针异常,
    如果debug跟进去的话,会执行调用,连接数据库调用到getStatement()时,报错:
    [INFO] Unable to sendViaPost to url[http://localhost:8080/axis2/services/TermInfo]
    java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
    at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
    at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
    at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
    at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:364)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:208)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
    at dataaccess.TermInfoStub.ifTheTermIsExistByLabelCh(TermInfoStub.java:5900)
    at dataaccess.TermInfoTest.testifTheTermIsExistByLabelCh(TermInfoTest.java:791)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    3./**
      * Auto generated method signature
      *
      * @see dataaccess.TermInfo#ifTheTermIsExistById
      * @param ifTheTermIsExistById23
      *
      * @throws dataaccess.ExceptionException0 :
      */

     public dataaccess.TermInfoStub.IfTheTermIsExistByIdResponse ifTheTermIsExistById(

     dataaccess.TermInfoStub.IfTheTermIsExistById ifTheTermIsExistById23)

     throws java.rmi.RemoteException

     , dataaccess.ExceptionException0 {
      org.apache.axis2.context.MessageContext _messageContext = null;
      try {
       org.apache.axis2.client.OperationClient _operationClient = _serviceClient
         .createClient(_operations[12].getName());
       _operationClient.getOptions().setAction("urn:ifTheTermIsExistById");
       _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(
         true);

       addPropertyToOperationClient(
         _operationClient,
         org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
         "&");

       // create a message context
       _messageContext = new org.apache.axis2.context.MessageContext();

       // create SOAP envelope with that payload
       org.apache.axiom.soap.SOAPEnvelope env = null;

       env = toEnvelope(getFactory(_operationClient.getOptions()
         .getSoapVersionURI()), ifTheTermIsExistById23,
         optimizeContent(new javax.xml.namespace.QName(
           "http://dataAccess", "ifTheTermIsExistById")));

       // adding SOAP soap_headers
       _serviceClient.addHeadersToEnvelope(env);
       // set the message context with that soap envelope
       _messageContext.setEnvelope(env);

       // add the message contxt to the operation client
       _operationClient.addMessageContext(_messageContext);
       
       _serviceClient.getOptions().setProperty(HTTPConstants.SO_TIMEOUT,new Integer(600000));
       _serviceClient.getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(600000));

          
       // execute the operation client
       [color=#FF0000] _operationClient.execute(true);
    /*执行到此处时停止,捕捉到异常,如果跟进去的话,会执行连接数据库操作,但出现问题:[INFO] Unable to sendViaPost to url[http://localhost:8080/axis2/services/TermInfo]
    java.net.SocketTimeoutException: Read timed out */[/color]


       org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient
         .getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
       org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext
         .getEnvelope();

       java.lang.Object object = fromOM(_returnEnv.getBody()
         .getFirstElement(),
         dataaccess.TermInfoStub.IfTheTermIsExistByIdResponse.class,
         getEnvelopeNamespaces(_returnEnv));

       return (dataaccess.TermInfoStub.IfTheTermIsExistByIdResponse) object;

      } catch (org.apache.axis2.AxisFault f) {

       org.apache.axiom.om.OMElement faultElt = f.getDetail();
       if (faultElt != null) {
        if (faultExceptionNameMap.containsKey(faultElt.getQName())) {
         // make the fault by reflection
         try {
          java.lang.String exceptionClassName = (java.lang.String) faultExceptionClassNameMap
            .get(faultElt.getQName());
          java.lang.Class exceptionClass = java.lang.Class
            .forName(exceptionClassName);
          java.lang.Exception ex = (java.lang.Exception) exceptionClass
            .newInstance();
          // message class
          java.lang.String messageClassName = (java.lang.String) faultMessageMap
            .get(faultElt.getQName());
          java.lang.Class messageClass = java.lang.Class
            .forName(messageClassName);
          java.lang.Object messageObject = fromOM(faultElt,
            messageClass, null);
          java.lang.reflect.Method m = exceptionClass.getMethod(
            "setFaultMessage",
            new java.lang.Class[] { messageClass });
          m.invoke(ex, new java.lang.Object[] { messageObject });

          if (ex instanceof dataaccess.ExceptionException0) {
           throw (dataaccess.ExceptionException0) ex;
          }

          throw new java.rmi.RemoteException(ex.getMessage(), ex);
         } catch (java.lang.ClassCastException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         } catch (java.lang.ClassNotFoundException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         } catch (java.lang.NoSuchMethodException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         } catch (java.lang.reflect.InvocationTargetException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         } catch (java.lang.IllegalAccessException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         } catch (java.lang.InstantiationException e) {
          // we cannot intantiate the class - throw the original
          // Axis fault
          throw f;
         }
        } else {
         throw f;
        }
       } else {
        throw f;
       }
      } finally {
       _messageContext.getTransportOut().getSender().cleanup(
         _messageContext);
      }
     }


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/5/23 9:31:00
     
     sxjida 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:12
      积分:119
      门派:W3CHINA.ORG
      注册:2007/11/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sxjida发送一个短消息 把sxjida加入好友 查看sxjida的个人资料 搜索sxjida在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看sxjida的博客2
    发贴心情 
    补充下,数据库连接在服务器端main()方法里做测试是连接成功,可以做数据库查询
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/5/23 10:38:00
     
     sxjida 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:12
      积分:119
      门派:W3CHINA.ORG
      注册:2007/11/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sxjida发送一个短消息 把sxjida加入好友 查看sxjida的个人资料 搜索sxjida在『 Web Services & Semantic Web Services 』的所有贴子 引用回复这个贴子 回复这个贴子 查看sxjida的博客3
    发贴心情 
    问题已解决,一方面是数据库驱动没有放到%TOMCAT_HOME%\webapps\axis2\WEB-INF\lib下面, 另一方面有服务调用超时问题,延长设置了响应时间
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/5/25 16:42:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Web Services & Semantic Web Services 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/7/11 2:19:48

    本主题贴数3,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    20,486.330ms