org.apache.axis.AxisFault: 服务器无法处理请求。 ---> 值不能为空。

org.apache.axis.AxisFault: 服务器无法处理请求。 ---> 值不能为空。
参数名: input
	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:609)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	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:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	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.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
	at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
	at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
	at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
	at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
	at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
	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 WebServiceTest.main2(WebServiceTest.java:82)
	at WebServiceTest.main(WebServiceTest.java:23)
服务器无法处理请求。 ---> 值不能为空。
参数名: input

  axisd调用webservice,明明写了参数,但代码调用还是报这个错,问题是参数也需要传namespace

try {
            String endpoint = "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
            String namespace="http://WebXml.com.cn/";
            String methodName="getSupportCityString";
            // 直接引用远程的wsdl文件
            // 以下都是套路
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(endpoint);
            call.setOperationName(new QName(namespace,methodName));
            call.setReturnType(XMLType.XSD_SCHEMA);
            call.setUseSOAPAction(true);
            //设置soapAction
            String soapAction = "http://WebXml.com.cn/getSupportCityString";
            call.setSOAPActionURI(soapAction);
            call.addParameter(new QName(namespace, "theRegionCode"),
                    XMLType.XSD_STRING,
                    ParameterMode.IN);// 接口的参数
//            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// 设置返回类型
            String temp = "31121";
            Schema result = (Schema) call.invoke(new Object[] { temp });
            for (MessageElement messageElement : result.get_any()) {
                System.out.println(messageElement.getAsString());
            }
            // 给方法传递参数,并且调用方法
            System.out.println("result is " + result);
        } catch (Exception e) {
            System.err.println(e.toString());
        }

  新增参数需要用下面的写法:

call.addParameter(new QName(namespace, "theRegionCode"),
XMLType.XSD_STRING,
ParameterMode.IN);
posted @ 2022-06-16 21:34  Gyoung  阅读(3122)  评论(0编辑  收藏  举报