0
package my.first.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("hello")
public class Hello {
// This method is called if TEXT_PLAIN is requested
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayHelloInPlainText() {
return "Hello world!";
}
http://stackoverflow.com/questions/2893796/create-hello-world-with-restful-web-service-and-jersey
// This method is called if HTML is requested
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHelloInHtml() {
return "<html> " + "<title>" + "Hello world!" + "</title>"
+ "<body><h1>" + "Hello world!" + "</body></h1>" + "</html> ";
}
}
這是我寫的web服務Restful的代碼。當我用測試客戶端發佈然後這個錯誤來了:如何發佈「Hello world」其他Web服務?
我該如何解決它?這僅與Rest有關,而不是與SOAP有關。
納文感謝名單了現在的工作,但我有一些更多的查詢將請helpp我,我可以有烏爾電子郵件ID,這樣我可以問在web服務 – user2782773
一些小小的問題HTTP :// localhost:8080/HelloRestefullClient/sampleHelloProxy/TestClient.jsp這是我的http:// localhost:8080/HelloRestefullClient/sampleHelloProxy/TestClient.jsp url來測試客戶端如何使URl可以在另一個應用程序中使用 – user2782773
嗨,澤西有客戶端庫使用,你可以調用你的REST服務,除此之外,你可以通過任何其他HTTP客戶端,如Java HttpUrlConnection或Apache Http客戶端調用您的REST服務。 –