首页 > 编程语言 > 详细

java调用wsdl xfire和cxf两种方式

时间:2016-01-29 21:05:19      阅读:207      评论:0      收藏:0      [点我收藏+]
     xfire 如下:
       String spID = ""; String password = ""; String accessCode = ""; String content = ""; String mobileString = ""; String url = ""; String operateName = "Submit"; Object[] object = new Object[]{spID,password,accessCode,content,mobileString}; org.codehaus.xfire.client.Client client = new org.codehaus.xfire.client.Client(new URL(url)); String a = client.getUrl(); Object[] results = client.invoke(operateName, object); System.out.println("aaaa:" + results[0]);


cxf

        JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
        Client client = factory.createClient(url);

        // 下面一段处理 WebService接口和实现类namespace不同的情况 

        // CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
        Endpoint endpoint = client.getEndpoint();
        QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operateName);
        BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
        if (bindingInfo.getOperation(opName) == null) {
        for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
        if (operateName.equals(operationInfo.getName().getLocalPart())) {
            opName = operationInfo.getName();
            break;
            }
          }
        }

      Object[] res = client.invoke(opName, object);





 

java调用wsdl xfire和cxf两种方式

原文:http://www.cnblogs.com/xlh91118/p/5169768.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!