我正在使用xml服务来获取响应,但我从service获取null响应。请帮助我解决这个问题.............
通过这项服务我发送用户名和密码,但是错误和正确将成功部分,因为我的服务将返回nulll值但它将在POSTMAN中正常工作.........
<script>
function callXMLConnection() {
alert("call Xml method call");
var un=$("#user").val();
var pw=$("#pwd").val();
var myurl="http://192.162.1.153/EServices/retrieve.aspx";
$.support.cors = true;
$.ajax({
data :"",
type: "POST",
url:myurl,
dataType: "xml",
contentType: "application/xml; charset=utf-8",
crossDomain:true,
success: function(data, textStatus, jqXHR){
alert("text : "+data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("No data found."+jqXHR);
}
});
}
$(document).unbind('pageinit').bind('pageinit', function () {
$("#userInfo").click(function () {
callXMLConnection();
});
});
</script>
这是我的获取身份验证方法
Private Sub GenerateXMLPostMethod(ByVal Format As String, ByRef iostream As Stream)
Try
Dim WSCOMMAND As String, TMPSTR As String As String
WS_USERID = Page.Request.Item("username")
WSCOMMAND = Page.Request.Item("command")
Select Case WSCOMMAND
Case "get_authentication"
Application_Error("Responded at:" & System.DateTime.Now)
WSCOMMAND = Page.Request.Item("username")
TMPSTR = Page.Request.Item("password")
DeviceID = Page.Request.Item("deviceid")
TMPSTR = Page.Request.Item("command")&"&username"&Page.Request.Item("username") & "&password"&Page.Request.Item("username")
TMPSTR = Page.Request.Item("password") 'Passowrd
LBFN_GET_USER(WSCOMMAND, TMPSTR, iostream)
End Select
Catch ex As Exception
Application_Error("GenerateXMLPostMethod :" + ex.Message)
End Try
答案 0 :(得分:0)
在代码中没有数据(用户名,密码)传递给服务器,修改你的代码,用
data:"" // sending null value
像这样使用
data:{usename:un,password:pw}
在服务器页面中,您可以使用post方法
从用户名,密码中获取值