调用接口报错:
endpoint:http://localhost:8080/U3Interface/services/FindData?wsdl;KEY:ctcc2u3BBqYXZhLnV; type:CTCCU3AZ; startDate:2017-04-01 09:23:33; args.length:5
AxisFaultfaultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:wenhao-pc
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
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:2973)
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.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.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
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 com.ketech.test.TestfindData.main(TestfindData.java:36)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [util.c:838]
1、把文件 server-config.wsdd 中 style 和 use 去掉即可;
<service name="FindData" provider="java:RPC" style="document" use="literal"> <parameter name="className" value="com.ketech.Interface.FindData"/> <parameter name="allowedMethods" value="findDataProcess"/> <parameter name="scope" value="Application"/> </service>
下面是调用类:
package com.ketech.test;
import java.util.Vector;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import com.ketech.util.EncryptUtil;
import com.ketech.util.ObjectSerialize;
public class TestfindData {
public static void main(String[] args) {
args = new String[] { "http://localhost:8080/U3Interface/services/FindData?wsdl", "ctcc2u3BBqYXZhLnV","CTCCU3AZ", "2017-04-01 09:23:33","2017-04-02 08:39:20"};
if(args.length<3){
System.out.println("sample : url key systemType quantity");
return;
}
String endpoint = args[0];
String KEY = args[1];
String type = args[2];
String startDate=args[3];
String endDate=args[4];
System.out.println("endpoint:"+endpoint+";KEY:"+KEY+"; type:"+type+"; startDate:"+startDate +"; args.length:"+args.length);
Service service = new Service();
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//call.setReturnClass(org.w3c.dom.Element.class);
//call.setReturnQName("http://xml.apache.org/xml-soap");
call.setOperationName(new QName("findDataProcess"));
String ret = (String) call.invoke(new Object[] {type,startDate,endDate});
System.out.println("****************!!!!!!*********" + ret + "'");
byte[] bb = EncryptUtil.decryptData(ret, KEY);
@SuppressWarnings("unchecked")
Vector<Vector> v = (Vector<Vector>) ObjectSerialize.deserialize(bb);
System.out.println("##:"+v);
for (int i = 0; i < v.size(); i++) {
Vector vi = (Vector) v.get(i);
System.out.println(vi);
System.out.println(vi.get(vi.size() - 2));
}
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}