SpringBoot调用webServices接口

SpringBoot调用webServices接口

  • 导入jar包
  • 代码部分

导入jar包

		
        <dependency>
            <groupId>org.apache.cxfgroupId>
            <artifactId>cxf-spring-boot-starter-jaxwsartifactId>
            <version>3.2.4version>
        dependency>
        <dependency>
            <groupId>org.apache.cxfgroupId>
            <artifactId>cxf-rt-transports-http-jettyartifactId>
            <version>3.2.4version>
        dependency>

代码部分

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Value;

public class BjinfoSend {

	public static String send(String eventJson,String clientId){
		
		JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://localhost:8088/services/EventWebService?wsdl");
        //client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME, PASS_WORD));
        Object[] objects = new Object[0];
        // invoke("方法名",参数1,参数2,参数3....);
        try {
			objects = client.invoke("revice", eventJson,clientId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return objects[0].toString();
	}
}

你可能感兴趣的:(SpringBoot)