zoukankan      html  css  js  c++  java
  • java调用wsdl xfire和cxf两种方式

         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);





  • 相关阅读:
    软件工程第二次作业
    第一次作业
    理论物理特训-02
    左神-06 二叉树
    哲学通论之人-05(end)
    哲学通论之人-04
    左神-05 二分搜索(多看几遍)
    哲学通论之人-01
    航空母舰-04(end)
    题解 P3126 【[USACO15OPEN]回文的路径Palindromic Paths】
  • 原文地址:https://www.cnblogs.com/xlh91118/p/5169768.html
Copyright © 2011-2022 走看看