2012-02-20 24 views
0

我在JBoss上測試簡單的Restful服務時遇到問題。部署在JBoss上的RESTful服務沒有響應

我已經構建了該項目並部署到JBoss很好。這是使用Java我的部署寫着:

import javax.ws.rs.core.Application; 

public class Deployer extends Application { 

} 

這是我的web.xml:

<?xml version="1.0"?> 

<web-app> 
    <servlet-mapping> 
     <servlet-name>com.mxyy.orderservice.deploy.Deployer</servlet-name> 
     <url-pattern>/orderservice/*</url-pattern> 
    </servlet-mapping> 
</web-app> 

這是我的RESTful服務接口Scala中寫:

@Provider 
@Path("/customers") 
trait ICustomerService { 
    @POST 
    @Consumes(Array("application/xml")) 
    def createCustomer(is: InputStream): Response 

    @GET 
    @Path("{id}") 
    @Produces(Array("application/xml")) 
    def getCustomer(@PathParam("id") id: Int): StreamingOutput 

    @PUT 
    @Path("{id}") 
    @Consumes(Array("application/xml")) 
    def updateCustomer(@PathParam("id") id: Int, is: InputStream): Unit 
} 

此接口實現。

後,我部署到JBoss,我試圖通過鍵入訪問服務:

http://localhost:8080/orderservice/customers/1 

的瀏覽器響應

HTTP Status 404 - /orderservice/customers/1  

type Status report  
message /orderservice/customers/1  
description The requested resource (/orderservice/customers/1) is not available. 

有人能指出我做錯了什麼?

非常感謝。

回答

0

我認爲一切都很好,除了一個小錯誤是「​​/」。 只需編輯爲:

@Provider 
@Path("/customers") 
trait ICustomerService { 
@POST 
@Consumes(Array("application/xml")) 
def createCustomer(is: InputStream): Response 

@GET 
@Path("/{id}") 
@Produces(Array("application/xml")) 
def getCustomer(@PathParam("id") id: Int): StreamingOutput 

@PUT 
@Path("/{id}") 
@Consumes(Array("application/xml")) 
def updateCustomer(@PathParam("id") id: Int, is: InputStream): Unit 
} 

通知我,如果它的工作原理。 :)

+0

嗨。感謝您的回覆。不幸的是,這並沒有解決問題:( – Kevin 2012-02-21 09:42:13