已经知道:wsdl地址
用CXF编写一webservice 远程客户端

解决方案 »

  1.   

    使用java方式访问之一:import javax.xml.namespace.QName;
    import javax.xml.ws.Service;
    import javax.xml.ws.soap.SOAPBinding;public class HelloWorldClient { private final static QName SERVICE_NAME
      =new QName("http://server.ws.demo/", "HelloWorld");
    private final static QName PORT_NAME
      =new QName("http://server.ws.demo/", "HelloWorldPort");

    /**
     * @param args
     */
    public static void main(String[] args) {
    Service service = Service.create(SERVICE_NAME);
    String endpointAddress = "http://localhost:8080/HelloWorld"; //wsdl地址
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
    HelloWorld hw = service.getPort(HelloWorld.class); //发布服务的接口
    System.out.println(hw.sayHi("  cvicse!")); //接口方法调用
    }}
      

  2.   

    最简单的方法是用cxf的wsdl2java命令先生产clien stub,在远程app中使用client stub就行。
      

  3.   

    public class TestWebServiceUseAxis {
    public static void main(String[] args) {
    try {
    String url = "http://219.148.199.4:9082/gsNotifyWS/services/gsNotify";
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(url));
    call.setOperationName(new QName                ("http://soapinterop.org/","orderRelationUpdateNotifyReq"));  
    call.invoke(new Object[]{"99","99",99,"99",99});
    } catch (ServiceException e) {
    e.printStackTrace();
    System.out.println("Service 获取 Call对象失败!");
    } catch (MalformedURLException e) {
    e.printStackTrace();
    System.out.println("new java.net.URL(url)错误!");
    } catch (RemoteException e) {
    e.printStackTrace();
    System.out.println("远程错误!");
    }
    }
    }
      

  4.   

    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    client = dcf.createClient("http://127.0.0.1:9001/services/systemserver?wsdl");
    Object[] re1 = client.invoke("方法名", "参数");
    if (re1 != null && re1.length != 0) {
    System.out.println("一共有几个参数:" + re1.length);
    for (int i = 0; i < re1.length; i++) {
    System.out.println("返回的第" + (i + 1) + "个值: " + new String((byte[])re1[i]));
    }
    }
      

  5.   

    客房端要使用JaxWsDynamicClientFactory 应该在调入哪些包? 我是个菜菜菜鸟
      

  6.   

    参考我在这个帖子 3 楼的回复,也是用 CXF 调用远程 Web 服务的http://topic.csdn.net/u/20091016/22/56aebb07-cd7b-4c7b-a38a-ebd7f35392c8.html
      

  7.   

    如果你用的是 JDK 6 那很多 jar 包是不需要的,因为 JDK 6 已经将 JAX-WS 和 JAXB 集成到 J2SE 中去了。