public static void main(String[] args) {
try {
String endpoint = "http://192.168.0.121/WsPowerFlow.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
QName qn=new QName("http://tempuri.org/","NetLossCalculationWithDB");
call.setOperationName(new QName("http://tempuri.org/","NetLossCalculationWithDB"));
call.addParameter(new QName("http://tempuri.org/", "A"),Constants.XSD_INT, ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "B"),Constants.XSD_INT, ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "C"),Constants.XSD_INT, ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "D"),Constants.XSD_INT, ParameterMode.IN);
call.registerTypeMapping(HashMap.class, qn, new MapSerializerFactory(HashMap.class,qn), 
new MapDeserializerFactory(HashMap.class,qn));
call.setReturnType(Constants.XSD_ANY);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/NetLossCalculationWithDB");
//call.setReturnClass(org.w3c.dom.Element.class);
call.setReturnQName(new QName("http://xml.apache.org/xml-soap"));
Object params = new Object[] { 0, 7, 0, 24 };
System.out.println("Successful= " + call.invoke((Object[]) params));
} catch (Exception e) {
System.err.println(e.toString());
}
}
//call.setReturnClass(org.w3c.dom.Element.class);如果不注释就会返回null,如果注释了就会报以下的错误。
- Exception:
org.xml.sax.SAXException: Deserializing parameter 'NetLossCalculationWithDBResult':  could not find deserializer for type {http://www.w3.org/2001/XMLSchema}any
at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.webservice.Test.main(Test.java:39)
org.xml.sax.SAXException: Deserializing parameter 'NetLossCalculationWithDBResult':  could not find deserializer for type {http://www.w3.org/2001/XMLSchema}any
求高手帮忙。。