[英]How to call a php web service from a java application without any external dependancies?
我創建了一個非常簡單的php Web服務,其中沒有WSDL。 我找到了一種從Java應用程序調用它的方法。
String endpoint = "http://localhost/webser/simple_server.php";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( new QName("urn://tyler/req") );
String ret=(String)call.invoke("readfat",new Object[]{});
System.out.print(ret);
它工作正常,並提供輸出。 但是它需要外部jar文件,例如axis1-3.jar,commons-discovery,commons-logging ..... etc。 我想知道是否有一種無需任何外部依賴即可使用Web服務的方法嗎? 我的實際需要是使用Applet的Web服務。 因此,我不能容忍外部貶低。 JAX-WS可以用於此目的嗎?
如果您想調用Web服務,則只需自己發出HTTP請求即可。
如果您不希望任何外部依賴項,則標准庫中使用的類是java.net.HttpURLConnection
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.