humulin520 2014-10-28 18:09 采纳率: 0%
浏览 443
已采纳

java调用service接口异常

最近做个项目,要用java调用webservice接口,写个测试类就报错了,第一次弄这个,求大神指点,以下是代码及错误信息:

try {
            String endpoint = "http://www.xdz.gov.cn:8080/system/services/UserService?wsdl";
            //直接引用远程的wsdl文件
            Service service = new Service();
           Call call = (Call)service.createCall();
           call.setTargetEndpointAddress(new URL(endpoint));
            call.setOperationName("userLogin");//WSDL里面描述的接口名称
            call.addParameter("servicesuserinfo", org.apache.axis.encoding.XMLType.XSD_STRING,
            javax.xml.rpc.ParameterMode.IN);//接口的参数
            call.addParameter("useraccount", org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);//接口的参数
            call.addParameter("password", org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);//接口的参数
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型  


            String result = (String)call.invoke(new Object[]{PwdCrypt.encrypt(encode),"admin",PwdCrypt.encrypt("!2@:?+)JUXDZ^%&*")});
            //给方法传递参数,并且调用方法
            System.out.println("result is "+result);
     }
     catch (Exception e) {
            e.printStackTrace();
     }
异常信息如下:

log4j:ERROR Could not find value for key log4j.appender.R
log4j:ERROR Could not instantiate appender named "R".
[QC] INFO [main] org.apache.axis.client.Call.invoke(1853) | Mapping Exception to AxisFault
     AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultString: java.lang.reflect.InvocationTargetException
 faultActor: null
 faultDetail: 
hostname: localhost.localdomain


java.lang.reflect.InvocationTargetException
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:135)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:942)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1789)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2965)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
at org.apache.axis.client.Call.invokeEngine(Call.java:2132)
at org.apache.axis.client.Call.invoke(Call.java:2102)
at org.apache.axis.client.Call.invoke(Call.java:1851)
at org.apache.axis.client.Call.invoke(Call.java:1777)
at org.apache.axis.client.Call.invoke(Call.java:1315)
at com.hz.sunday.gaoxinfccrm.utils.HttpRequestUtil.main(HttpRequestUtil.java:116)

  • 写回答

1条回答 默认 最新

  • 沉默王二 Java领域优质创作者 2014-10-28 18:51
    关注

    我在做webservice的开始阶段,也试过你上面的方式,但是发现太不好使,且抛开你上面的错误不说,我觉得你可能使用Eclipse自带的webservice和webservice client来开发比较好,方便,快捷,简单。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀