[ERROR] “不支持使用 SOAP 编码。SOAP 扩展元素包含 use=“encoded“ “ 无法解析 WSDL。

下载axis-1_4,地址https://archive.apache.org/dist/ws/axis/1_4/

解压,进入D:\axis-1_4\lib

执行命令

java -cp mail.jar;saaj.jar;jaxrpc.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar;axis.jar;activation.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java D:\TmriOutNewAccess.xml -p com.lxw.webservice

 生成的文件

调用

public class test {
    public static void main(String[] args) throws RemoteException {
        TmriJaxRpcOutNewAccessService locator = new TmriJaxRpcOutNewAccessServiceLocator();
        TmriOutNewAccessSoapBindingStub stub = (TmriOutNewAccessSoapBindingStub) locator.getTmriOutNewAccess();
        String result = stub.queryObjectOut("", "", "", "", "", "", "", "", "");
        System.out.println("result:" + result);
    }
}

Intellij Idea 下 生成WebServiceClient (WS客户端)参考:https://www.cnblogs.com/felordcn/p/12142597.html

 

SpringBoot调用WebService接口

pom

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
    <version>3.2.4</version>
</dependency>

调用

import com.alibaba.fastjson.JSONObject;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

public class WsTest {

   public static void main(String[] args) {

      // 创建动态客户端
      JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
      Client client = dcf.createClient("http://域名/api/notify?wsdl");
      Object[] objects = new Object[0];
      try {
         //传入参数
         objects = client.invoke("queryObjectOut", "参数1", "参数2", "参数3", "参数4", "参数5", "参数6", "参数7", "参数8", "参数9");
         System.out.println("返回数据:" + JSONObject.toJSONString(objects[0]) );
      } catch (java.lang.Exception e) {
         e.printStackTrace();
      }

   }
}

 

posted @ 2023-03-07 11:39  天天代码码天天  阅读(150)  评论(0编辑  收藏  举报  来源