Ajax和WCF流 - 它是如何工作的 [英] Ajax and WCF Stream - How does it work

查看:64
本文介绍了Ajax和WCF流 - 它是如何工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是初级开发人员,之前我认为这是理所当然的。



我想知道是否有人可以向我解释ajax如何请求和WCF服务在接受Stream作为输入参数的WCF合同方法方面工作。例如下面



Ajax



Hi so i'm junior developer and before now i've took this for granted.

I was wondering if someone could explain to me how ajax requests and WCF Services work in terms of WCF contract methods accepting a Stream as input paramaters.Example below

Ajax

$.ajax({
   type: 'POST',
   dataType: 'json',
   data: postData,
   url: Application.settings.marketingServiceUrl + 'Update' + id,
   success: function (response) {
        if (response)
	callback(response);
   },
    error: function (request, errorText, errorCode) {
    }
});





然后webService合同代码是



then webService Contract code is

[OperationContract]
        [WebInvoke(Method = "POST",
        BodyStyle = WebMessageBodyStyle.Bare,
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "Update/")]
        Stream UpdateIndustry(Stream postedJson);





那么它如何知道将流发布到哪里?和其他合同方法一样,我只使用UriTemplate中的Id或值来传递给方法,例如



so how does it know where to get the stream postedJson? as in other contract methods i've used just Id's or values in the UriTemplate to pass into the method, e.g

<pre lang="c#">

UriTemplate = "Load/{industryGuid}/{industryLanguage}")]
        Stream LoadIndustry(string industryGuid, string industryLanguage);





但即便如此我也不确定它是如何知道在UriTemplate中查找这些属性(除了它们的命名相同)



关于这个问题的任何帮助都会对我有很大帮助,因为我很难理解它



but even then i'm not sure how it knows to look in the UriTemplate for those properties (other than they're named the same)

Any help on this matter would greatly help me, as i struggled to get my head around it

推荐答案

.ajax({
type:' POST'
dataType:' json'
data:postData,
url:Application.settings.marketingServiceUr l + ' 更新' + id,
成功: function (response){
if (response)
callback(response);
},
错误: function (request,errorText,errorCode){
}
});
.ajax({ type: 'POST', dataType: 'json', data: postData, url: Application.settings.marketingServiceUrl + 'Update' + id, success: function (response) { if (response) callback(response); }, error: function (request, errorText, errorCode) { } });





然后webService合同代码是



then webService Contract code is

[OperationContract]
        [WebInvoke(Method = "POST",
        BodyStyle = WebMessageBodyStyle.Bare,
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "Update/")]
        Stream UpdateIndustry(Stream postedJson);





所以它怎么知道在哪里获得流发布的Json ?和其他合同方法一样,我只使用UriTemplate中的Id或值来传递给方法,例如



so how does it know where to get the stream postedJson? as in other contract methods i've used just Id's or values in the UriTemplate to pass into the method, e.g

<pre lang="c#">

UriTemplate = "Load/{industryGuid}/{industryLanguage}")]
        Stream LoadIndustry(string industryGuid, string industryLanguage);





但即便如此我也不确定它是如何知道在UriTemplate中查找这些属性(除了它们的命名相同)



任何有关此事的帮助都会对我有很大的帮助,因为我很难理解它



but even then i'm not sure how it knows to look in the UriTemplate for those properties (other than they're named the same)

Any help on this matter would greatly help me, as i struggled to get my head around it


这篇关于Ajax和WCF流 - 它是如何工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆