求一段java连接WCFRest的post请求的代码片段

J2EE 码拜 8年前 (2016-05-13) 1043次浏览
C#片段:

        [WebInvoke(UriTemplate = "TestPost", ResponseFormat = WebMessageFormat.Json)]
        public String TestPost(String LoginUserName)
        {
            return "Post:" + LoginUserName;
        }
        [WebGet(UriTemplate = "TestGet/{LoginUserName}", ResponseFormat = WebMessageFormat.Json)]
        public String TestGet(String LoginUserName)
        {
            return "Get:" + LoginUserName;
        }

URI:
get方式
http://yxcww.cn/OSService/TestGet/123
post方式
http://yxcww.cn/OSService/TestPost
补充:
get和post方式,在C#客户端,都可以请求成功。
post方式,假如用java,不传递参数的时候可以成功,但是传递参数就会报错。

解决方案

25

同求。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求一段java连接WCFRest的post请求的代码片段
喜欢 (0)
[1034331897@qq.com]
分享 (0)