Url Address for RestEasy
olasamuel Mar 3, 2011 12:01 PMHi All,
Please, can somebody help me. I am new to reastful services. I have created a restful services and I have made the necessary settings. below is the method and the likes
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Stateful
@Scope(ScopeType.SESSION)
@Name("subTopUpManager")
@Path("/subTopUp")
public class SubscriberTopUpManagerBean implements SubscriberTopUpmanager, Serializable{
This is the method
that I am pointing to
@GET
@Path("/{reserveUnits}")
@Produces(MediaType.TEXT_PLAIN)
public long reserveUnits(Integer subId, Long requestedUnits) {
String balInquiry = "select balance from SubTopUp where subscriber_id=:subId";
Query balInquiryQuery = entityManager.createQuery(balInquiry);
long allocatedUnits = 0;
Long bal = (Long) balInquiryQuery.setParameter(balInquiry, subId).getSingleResult();
if ((bal - requestedUnits) < 0 )
{
FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, "Insufficient Fund.", "Please, Load some units");
} else
{
allocatedUnits=requestedUnits;
long newBalance = bal-allocatedUnits;
subTopUp = new SubTopUp();
String balQuery = "Update SubTopUp SET balance = :newBalance";
Query query = entityManager.createQuery(balQuery);
subTopUp = (SubTopUp) query.setParameter(balQuery, newBalance).getSingleResult();
System.out.println("I just got here");
}
return allocatedUnits;
}
This is my settings in web.xml
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
and this is the settings components.xml
<resteasy:application resource-path-prefix="/v2">
<resteasy:media-type-mappings>
<key>xml</key>
<value>application/xml</value>
</resteasy:media-type-mappings>
</resteasy:application>
When I run the application, I then point my uri address to http://146.64.19.208:8080/admin/seam/resource/v2/subTopUp/reserveUnits/
But what I got is HTTP Status 404 - Can someone please tell me what I am doing wrong and how should I do this. Your help is greatly and highly appreciated. Thank you
Please, can somebody help me. I am new to reastful services. I have created a restful services and I have made the necessary settings. below is the method and the likes
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Stateful
@Scope(ScopeType.SESSION)
@Name("subTopUpManager")
@Path("/subTopUp")
public class SubscriberTopUpManagerBean implements SubscriberTopUpmanager, Serializable{
This is the method
that I am pointing to
@GET
@Path("/{reserveUnits}")
@Produces(MediaType.TEXT_PLAIN)
public long reserveUnits(Integer subId, Long requestedUnits) {
String balInquiry = "select balance from SubTopUp where subscriber_id=:subId";
Query balInquiryQuery = entityManager.createQuery(balInquiry);
long allocatedUnits = 0;
Long bal = (Long) balInquiryQuery.setParameter(balInquiry, subId).getSingleResult();
if ((bal - requestedUnits) < 0 )
{
FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, "Insufficient Fund.", "Please, Load some units");
} else
{
allocatedUnits=requestedUnits;
long newBalance = bal-allocatedUnits;
subTopUp = new SubTopUp();
String balQuery = "Update SubTopUp SET balance = :newBalance";
Query query = entityManager.createQuery(balQuery);
subTopUp = (SubTopUp) query.setParameter(balQuery, newBalance).getSingleResult();
System.out.println("I just got here");
}
return allocatedUnits;
}
This is my settings in web.xml
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
and this is the settings components.xml
<resteasy:application resource-path-prefix="/v2">
<resteasy:media-type-mappings>
<key>xml</key>
<value>application/xml</value>
</resteasy:media-type-mappings>
</resteasy:application>
When I run the application, I then point my uri address to http://146.64.19.208:8080/admin/seam/resource/v2/subTopUp/reserveUnits/
But what I got is HTTP Status 404 - Can someone please tell me what I am doing wrong and how should I do this. Your help is greatly and highly appreciated. Thank you