当我用java调用.net的webservice的时候 没有报错 能返回值 但就是传参过去的时候 不起作用 看服务端值是没有过去了
之前代码如下:
Service service = new Service();
String ret =""; Call call = null; try { call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(Globals.endPointReference)); call.setOperationName(new QName(Globals.targetNamespace,name)); call.addParameter(new QName(Globals.targetNamespace,"stationID"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"moduleID"), XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"startTime"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"endTime"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setSOAPActionURI(Globals.targetNamespace+name); ret= (String)call.invoke(new Object[]{stationID,moduleID,startTime,endTime}); logger.info(name+"告警接口返回的值为 "+ret); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); }之后发现原来是调用。net的时候 只能全部用string类型 然后能正确的传过去了 代码如下
Service service = new Service();
String ret =""; Call call = null; try { call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(Globals.endPointReference)); call.setOperationName(new QName(Globals.targetNamespace,name)); call.addParameter(new QName(Globals.targetNamespace,"stationID"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"moduleID"), XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"startTime"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(Globals.targetNamespace,"endTime"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setSOAPActionURI(Globals.targetNamespace+name); ret= (String)call.invoke(new Object[]{stationID,String.valueOf(moduleID),startTime,endTime}); logger.info(name+"告警接口返回的值为 "+ret); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); }