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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐