Interface test for Android and Java background

Source: Internet
Author: User

1. There are two types of interface between Android app client and background: @POST and @get


@POST

@Path ("/updateuserdetail/")

@Consumes ("Application/x-www-form-urlencoded;encoding=utf-8")

@Override

Public Appbean Updateuserdetail (@FormParam ("username") String username,

@FormParam ("password") String password,

@FormParam ("occupation") String occupation,

@FormParam ("income") String income,

@FormParam ("email") String email,

@FormParam ("Phonenum") String Phonenum,

@FormParam ("married") String married) {}

------------------------------------------------------------------------------------------

@GET

@Path ("/goodslistbytype/{pageno}/{type}")

@Override

Public Appbean getgoodslist (@PathParam ("PageNo") String PageNo,

@PathParam ("type") String type) {}

-------------------------------------------------------------------------------------------


The @POST interface can be tested directly from the Address bar:

For example, the above interface, the address bar directly input:

http://localhost: Port number/project name/api/api/goodslistbytype/pageno/type/

The first API is a struts.xml configuration

(<constant name= "Struts.action.excludePattern" value= "/api/.*"/>),

The latter one is applicationcontext.xml configured

<jaxrs:server address= "/api" >

<jaxrs:serviceBeans>

<ref bean= "Appservice"/>

</jaxrs:serviceBeans>

<jaxrs:providers>

<bean class= "Org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider"/>

</jaxrs:providers>

</jaxrs:server>

But the @get method is not directly in the path central to obtain, to borrow external tools or write a test class, of course, I chose the former, online Baidu found the big God said postman Google browser plug-in , their own groping to test, no longer worry about interface debugging.

The Get interface is as follows:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/77/04/wKioL1ZhDvHRDajGAACgVP3Wq38086.png "title=" Get.png "alt=" Wkiol1zhdvhrdajgaacgvp3wq38086.png "/>

The post interface is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/77/05/wKiom1ZhDqPTEx0xAADL145zZ5o542.png "title=" Post.png "alt=" Wkiom1zhdqptex0xaadl145zz5o542.png "/>



This article is from the "Qin Feng" blog, make sure to keep this source http://leoxia.blog.51cto.com/10825018/1719483

Interface test for Android and Java background

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.