WebService笔记-创新互联
WebService服务端框架:jersey

WebService调用方式:jersey、http、spring RestTemplate
Server:
@Configuration
public class ApplicationConfig {
@Named
static class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
this.packages("com.lenovo.li.content.controllers");
}
}
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper;
}
}Pom
org.springframework.boot spring-boot-starter-jersey
Controller
@Named
@Path("/Test")
public class RestController {
@POST
@Path("/get/{url}")
@Produces(MediaType.APPLICATION_JSON)
public Test getTestContent(@PathParam("url") final String url, @RequestBody Context context)
throws JsonParseException, JsonMappingException, IOException {
}
@PUT
@Path("/update/{url}")
@Produces(MediaType.APPLICATION_JSON)
public Test updateTestContent(@PathParam("url") final String url, @RequestBody Page page)
throws JsonParseException, JsonMappingException, IOException {
}
}Client
public class TestClient{
@Autowired
RestTemplate restTemplate;
public String getTestContent(String name, Context context) {
ResponseEntity response = restTemplate.postForEntity(url, context,String.class);
return response.getBody();
}
} ClientXml
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章题目:WebService笔记-创新互联
网站链接:http://www.jxjierui.cn/article/cdsoej.html


咨询
建站咨询
