回覆列表
  • 1 # CoreCode

    public static void main(String[] args) throws Exception { //這個是用cxf 客戶端訪問cxf部署的webservice服務 //千萬記住,訪問cxf的webservice必須加上namespace ,否則通不過 //現在又另外一個問題,傳遞過去的引數服務端接收不到 JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); org.apache.cxf.endpoint.Client client = dcf.createClient("http://localhost:8080/facelook/services/facelookWebService?wsdl"); //url為呼叫webService的wsdl地址 QName name=new QName("http://server.webservice.facelook.com/","getAlbumList"); //namespace是名稱空間,methodName是方法名 String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + " <facelook>" + " <condition>" + " <name>家</name>" + " <description></description>" + " <pageno></pageno>" + " <pagesize></pagesize>" + " </condition>" + " </facelook>"; //paramvalue為引數值 Object[] objects=client.invoke(name,xmlStr); //呼叫web Service//輸出呼叫結果 System.out.println(objects[0].toString()); }

  • 中秋節和大豐收的關聯?
  • 賣慘嗎?黃海波近照惹爭議,生活並非揭不開鍋,卻為何迫切想復出?