网上找一下了JAVA直接调用WebService Result的例子很少,几乎都是讲如何讲用SOAP的,,自已弄了个例子使用,发上来跟大家分享一下
服务器端代码:
package com.weixin.yzh.controller.wsTest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/WsTestContr")
public class WsTest {
@RequestMapping(value = "/hello", produces = "text/plain;charset=UTF-8")
public @ResponseBody
String hello() {
return "你好!hello";
}
}
客户端代码:
package com.weixin.yzh.controller.wsTest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/WsTestContr")
public class WsTest {
@RequestMapping(value = "/hello", produces = "text/plain;charset=UTF-8")
public @ResponseBody
String hello() {
return "你好!hello";
}
}
输出结果:
Output from Server:
你好!hello