在服务器上面部署了webservice服务端,如果想在本地编写客户端调用,可以这样编写
public class clientrun { public static void main(String[] args) { JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); org.apache.cxf.endpoint.Client client = dcf .createClient("http://128.125.10.123/ctgopt_scfa/CtgoptWebService?wsdl"); // url为调用webService的wsdl地址 QName name = new QName("http://webservice.hcycom.com/", "syncAllOpts"); // namespace是命名空间,methodName是方法名 String xmlStr = ""; // paramvalue为参数值 Object[] objects; try { objects = client.invoke(name); System.out.println(objects[0].toString()); } catch (Exception e) { e.printStackTrace(); } }
原文地址:https://www.cnblogs.com/dhqz/p/11177636.html
时间: 2024-10-30 13:25:15