开发者社区> 问答> 正文

java调用webservice接口?报错

最近做个项目,要用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)

展开
收起
爱吃鱼的程序员 2020-06-14 20:40:32 1039 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    楼主先用soapUI试试,看看是你的问题还是他的问题

    引用来自“南湖船老大”的评论

    楼主先用soapUI试试,看看是你的问题还是他的问题

    2020-06-14 20:40:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载