使用POST将XML数据传递到WCF服务方法 [英] Passing XML data to WCF service method using POST

查看:96
本文介绍了使用POST将XML数据传递到WCF服务方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建了一个WCF服务和方法来读取XML数据.但是在调用服务并从Java脚本传递XML时,服务方法被调用但无法读取参数,显示为NULL.

Created a WCF service and method to read XML data. But while calling service and passing XML from java script, service method is called but unable to read parameter, showing as NULL.

以下是我的代码:-

===================服务方法=========================

===================Service Method=========================

base64_encodedResume参数每次我调用parseresume方法时都会显示NULL值.

base64_encodedResume parameter shows NULL value everytime i call parseresume method.

推荐答案

您要实现哪个功能?

Which function do you want to achieve?

根据您的代码,您只需将字符串从客户端传递到服务即可.即使通过传递xml字符串,它也与XML无关.

Based on your code, you just pass a string from client to service. It is not related with XML even through you pass xml string.

要使base64_encodedResume获得价值,建议您尝试以下代码.

To make base64_encodedResume get value, I suggest you try below code.


('#Button1').click(function(){ 警报(呼叫"); var postData ='''<< Category>< categoryId> 007</categoryId>< categoryName> Ajax</categoryName></Category""'"
('#Button1').click(function () { alert('calling'); var postData = '"<Category><categoryId>007</categoryId><categoryName>Ajax</categoryName></Category>"';


. ({ 类型:"POST", 网址:"http://localhost/WCFRest/RestService.svc/ParseResume", contentType:"application/json", 数据:postData, 成功:功能(分辨率){ alert("XML:它起作用了!"); }, 错误:功能(分辨率){ alert("XML:不起作用!" + res.statusText); } }); });
.ajax({ type: "POST", url: "http://localhost/WCFRest/RestService.svc/ParseResume", contentType: 'application/json', data: postData , success: function (res) { alert("XML: it works! "); }, error: function (res) { alert("XML: not working! " + res.statusText); } }); });

        [OperationContract]
        [WebInvoke( Method = "POST", UriTemplate = "ParseResume")]
        string ParseResume(string base64_encodedResume);


这篇关于使用POST将XML数据传递到WCF服务方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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