CXF系列之JAX-WS規範的java實現方式
阿新 • • 發佈:2019-02-20
這裡執行結果為A,在Web服務呼叫過程中,可能經常出現超時的問題,但你切不可以為只要WSDL可以訪問,就代表Web服務一定可以訪問,因為是否可以訪問與SEI的實現類有關,而WSDL僅是SEI的一種XML表示。package com.test.client; import java.text.ParseException; import java.text.SimpleDateFormat; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import com.test.bean.Customer; import com.test.inter.service.IHelloService; public class SoapClient { public static void main(String[] args) throws ParseException { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress("http://localhost:8080/helloService"); factory.setServiceClass(IHelloService.class); Object o = factory.create(); IHelloService service = (IHelloService)o; Customer c1 = new Customer(); c1.setId(1L); c1.setName("A"); c1.setBirthday(new SimpleDateFormat("yyyy-MM-dd").parse("1993-03-06")); Customer c2 = new Customer(); c2.setId(2L); c2.setName("B"); c2.setBirthday(new SimpleDateFormat("yyyy-MM-dd").parse("1993-04-06")); Customer c3 = service.selectMaxAgeCustomer(c1, c2); System.out.println(c3.getName()); } }