两个系统之间需要通信,采用webservice的方式。服务端用jax-ws,客户端用axis,但是在运行的时候报错了
AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client faultSubcode: faultString: Cannot find dispatch method for {}updatecredit faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:Cannot find dispatch method for {}updatecredit 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 org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) 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.landray.kmss.Expand.WebServiceClinet.updateCredit(WebServiceClinet.java:55) at com.landray.kmss.Expand.Test.main(Test.java:9) {http://xml.apache.org/axis/}hostname:JORT-064291963D Cannot find dispatch method for {}updatecredit 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 org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) 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.landray.kmss.Expand.WebServiceClinet.updateCredit(WebServiceClinet.java:55) at com.landray.kmss.Expand.Test.main(Test.java:9)
private static final String endporit="http://localhost:8080/financing/SpyService"; public static void updateCredit(String id,String total,String financing,String margin){ Service service = new Service(); Call call; String sssoapxmlns = "http://webservice.financing.gjzq.com/"; try { call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endporit)); call.setOperationName("updatecredit"); call.addParameter("id", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("total", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("financing", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("marginline", XMLType.XSD_STRING, ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setUseSOAPAction(true); String ret = (String) call.invoke(new Object[] { id, total, financing, margin }); System.out.println(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(); } }
private static final String endporit="http://localhost:8080/financing/SpyService"; public static void updateCredit(String id,String total,String financing,String margin){ Service service = new Service(); Call call; String sssoapxmlns = "http://webservice.financing.gjzq.com/"; try { call = (Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endporit)); // call.setOperationName("updatecredit");这种方式会报错,调用不到服务器程序 call.setOperationName(new QName(sssoapxmlns, "updatecredit")); //XMLType.XSD_STRING是org.apache.axis.encoding.XMLType call.addParameter("id", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("total", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("financing", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("marginline", XMLType.XSD_STRING, ParameterMode.IN); //下面的方式不行,服务端收不到参数值 // call.addParameter(new QName(sssoapxmlns, "id"), // org.apache.axis.encoding.XMLType.XSD_STRING, // javax.xml.rpc.ParameterMode.IN); // call.addParameter(new QName(sssoapxmlns, "total"), // org.apache.axis.encoding.XMLType.XSD_STRING, // javax.xml.rpc.ParameterMode.IN); // call.addParameter(new QName(sssoapxmlns, "financing"), // org.apache.axis.encoding.XMLType.XSD_STRING, // javax.xml.rpc.ParameterMode.IN); // call.addParameter(new QName(sssoapxmlns, "marginline"), // org.apache.axis.encoding.XMLType.XSD_STRING, // javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setUseSOAPAction(true); // 调用Webservice方法 // call.setSOAPActionURI("http://webservice.financing.gjzq.com/updatecredit"); String ret = (String) call.invoke(new Object[] { id, total, financing, margin }); System.out.println(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(); } }