2012-12-11 54 views
1

我已創建了一個CXF web服務示例:如何通過參數同時呼籲通過URL CXF web服務

@WebService 
public interface InterfaceWebService { 

    boolean doLogin(@WebParam(name="username")String username,@WebParam(name="password")String password); 

} 

Server代碼:

public class WebServer { 

    protected WebServer() throws Exception { 
     // START SNIPPET: publish 
     System.out.println("Starting Server"); 
     WebServiceImpl implementor = new WebServiceImpl(); 
     String address = "http://192.168.0.76:9000/sample"; 
     Endpoint.publish(address, implementor); 
     // END SNIPPET: publish 
    } 

    public static void main(String args[]) throws Exception { 
     new WebServer(); 
     System.out.println("Server ready..."); 

     Thread.sleep(5 * 60 * 5000); 
     System.out.println("Server exiting"); 
     System.exit(0); 
    } 
} 

WebServiceImpl類

@WebService(endpointInterface = "com.nextenders.services.InterfaceWebService", 
serviceName = "sample") 

public class WebServiceImpl implements InterfaceWebService{  


    @Override 
    public boolean doLogin(String username, String password) { 
      //Here some business logic call 
     return true; 
    } 


} 

現在我試圖通過以下URL調用此webservice: http://192.16 8.0.76:9000/sample/services/doLogin?username = abc & password = abc

但是我得到了wsdl xml結構。但我只需要特定的方法結果!! 我在這裏做錯了嗎?我如何在CXF web服務中傳遞參數?

回答

2

問題已解決。我忘了把服務名稱,並嘗試訪問直接的方法。

http://192.168.0.76:9000/sample/services/login_service/doLogin?username=abc &密碼= ABC