skwujinhua
发贴: 104
积分: 11
|
于 2009-07-28 11:20
//c# webservice [SoapRpcMethod(Action = "http://amsweb.dev.org/Sum", RequestNamespace = "http://amsweb.dev.org/S", ResponseNamespace = "http://amsweb.dev.org/S")] [WebMethod] public int sum(int [] str) { int sum = 0; for(int i = 0,sum=0;i < str.Length; i++) { sum+=str[i]; } return sum; }
//java mothed int []s = new int[]{1,1,1,1,1}; try{ System.out.println(s[0]); String serviceURL = "http://localhost:3719/AMSWEB/WSE/WebService.asmx"; Service service = new Service(); Call call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(serviceURL)); call.setOperationName(new QName("http://amsweb.dev.org/S","sum")); call.addParameter("str", org.apache.axis.encoding.XMLType.SOAP_ARRAY, ParameterMode.IN); call.setReturnType(org.apache.axis.encoding.XMLType.XSD_INT); call.setUseSOAPAction(true); call.setSOAPActionURI("http://amsweb.dev.org/Sum"); Integer res = (Integer)call.invoke(new Object[]{s}); }catch(Exception e) {
}
為什么我在eclipse 里傳數組給webservice返回0? 我看沒有傳過去值。調用以下二個參數的方法可以成功。 [SoapRpcMethod(Action = "http://amsweb.dev.org/Add", RequestNamespace = "http://amsweb.dev.org/T", ResponseNamespace = "http://amsweb.dev.org/T")] [WebMethod] public int Add(int a, int b) { int c = a + b; return c; }
哪個高手幫忙解決下?謝謝﹗
skwujinhua edited on 2009-07-28 11:25
|