本文介绍了如何获取WCF Restful Service的ref或out参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个WCF Restful Service,如下所示:
I have a WCF Restful Service, like below:
[OperationContract]
[WebInvoke(Method ="POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat =WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, UriTemplate = "CPSendInfo")]
int COSendTubeInfo(List<CPTXInfo> LstData,out string ErrMsg);
我想通过我的方法获得ErrMsg.怎么办?
I want get the ErrMsg by my method. How to do?
谢谢.有人可以尽快给我答复吗?
Thanks. Can some one reply me as soon as possible?
最紧急!!!
再次感谢.
Vince
推荐答案
您想得到Ajax的回复吗?如果尝试使用Fiddler或PostMan发送请求,则会收到如下所示的响应,并且可以检索json对象.
Did you want to get response from Ajax? If you try Fiddler or PostMan to send request, you will get response like below, and you could retrieve the json object.
{
"COSendTubeInfoResult": 123,
"ErrMsg": "Error"
}
这是一个简单的演示,可让Ajax获得响应.
Here is a simple demo for getting response by Ajax.
//WCF Rest Service
//IService
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, UriTemplate = "CPSendInfo")]
int COSendTubeInfo(int LstData, out string ErrMsg);
//Service
public int COSendTubeInfo(int LstData, out string ErrMsg)
{
ErrMsg = "Error";
return 123;
}
//Ajax Request
最好的问候,
Best Regards,
爱德华
这篇关于如何获取WCF Restful Service的ref或out参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!