使用axis(版本1.4)调用cxf服务端一直调用不成功,郁闷了一上午啊。经过google之后,嘻嘻~终于得以解决,讲述一下我的代码和解决过程
---使用了bboss mvc集成的cxf作为ws服务端
axis需要的jar包:axis.jar,axis-ant.jar,commons-discovery-0.2.jar,commons-logging-1.0.4.jar,jaxrpc.jar,log4j-1.2.8.jar,saaj.jar,wsdl4j-1.5.1.jar
---使用了bboss mvc集成的cxf作为ws服务端
axis需要的jar包:axis.jar,axis-ant.jar,commons-discovery-0.2.jar,commons-logging-1.0.4.jar,jaxrpc.jar,log4j-1.2.8.jar,saaj.jar,wsdl4j-1.5.1.jar
- import javax.jws.WebService;
- /**
- * <p>类的描述:XX数据同步</p>
- * @author XX
- * @version 1.0
- * @date 2011-8-9 上午11:38:20
- */
- @WebService(name="DataSynInf")
- public interface DataSynInf {
- /**
- * XXXXXXXXX
- * @param xml
- * @return
- */
- public String synMaterialAndBom(String xml);
- }
- public static void testDemo() {
- try {
- String endpoint = " http://172.16.81.65:8080/cxfservices/InterfacePort";
- // 调用过程
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new java.net.URL(endpoint));
- call.setOperationName("synMaterialAndBom");// WSDL里面描述的操作名称
- call.addParameter("xml",
- org.apache.axis.encoding.XMLType.XSD_STRING,
- javax.xml.rpc.ParameterMode.IN);// 操作的参数
- call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// 设置返回类型
- call.setUseSOAPAction(true);
- // 给方法传递参数,并且调用方法
- String temp = "good";
- Object[] obj = new Object[] { temp };
- String result = (String) call.invoke(obj);
- System.out.println("Result is : " + result);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }