WSClient客户端调用---codehaus.xfire

来源:互联网 发布:licecap for mac 编辑:程序博客网 时间:2024/06/05 02:21

感觉这个有问题,不知道为什么总是调用不通。大家试试。


package com.sinoservices.edi.ws;import java.net.MalformedURLException;import java.net.URL;import org.codehaus.xfire.XFireFactory;import org.codehaus.xfire.client.Client;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.service.binding.ObjectServiceFactory;import com.sinoservices.edi.ws.wsdl.client.HelloWorld;/** *  * @版权:SINOSERVICES 版权所有 (c) 2013 * @author:Mars * @version Revision 1.0.0 * @email:Mars.Wei@sinoservices.com * @see: * @创建日期:2017年2月24日 * @功能说明: * @begin * @修改记录: * @修改后版本          修改人      修改内容 * @2017年2月24日           Mars        创建 * @end */public class XFireWSClient {    public static void main(String[] args) throws Exception {//        clientUtil();        clientUtil11();        //        test2();    }    private static void clientUtil11() throws Exception {        Client client = new Client(new URL("http://127.0.0.1:9050/WolfDIPWebService/GatewayIn?wsdl"));        Object[] results = client.invoke("receiveFileData", new Object[] {"YWFh","mars"});        System.out.println(results[0]);            }    private static void clientUtil1() throws Exception {        Client client = new Client(new URL("http://localhost:8080/jdkwsdemo/HelloWorld?wsdl"));        Object[] results = client.invoke("doSomething", new Object[] {});        System.out.println(results[0]);    }    private static void clientUtil() throws Exception {                Service srvcModel = new ObjectServiceFactory().create(HelloWorld.class);        XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());        String helloWorldURL = "http://localhost:8080/jdkwsdemo/HelloWorld";        try {            HelloWorld srvc = (HelloWorld) factory.create(srvcModel, helloWorldURL);            String result = srvc.doSomething();            System.out.print(result);        } catch (MalformedURLException e) {            e.printStackTrace();        }    }        public static void test2() throws Exception      {          Service serviceModel = new ObjectServiceFactory().create(HelloWorld.class);        HelloWorld cmdbService = (HelloWorld)new XFireProxyFactory().create(serviceModel, "http://localhost:8080/jdkwsdemo/HelloWorld");        cmdbService.doSomething();        }  }


0 0