我试图使用jQuery UI自动完成与一个带有responseformate JSON的web服务进行交流,但我无法这样做.
我的web服务甚至没有执行,路径应该是正确的,因为错误消息不会抱怨这个.
令我震惊的是标题,响应是肥皂但请求是json,它应该是这样的吗?
Response Headersvisa källkod
Content-Type application/soap+xml; charset=utf-8
Request Headersvisa källkod
Accept application/json, text/javascript, */*
Content-Type application/json; charset=utf-8
Run Code Online (Sandbox Code Playgroud)
我得到的错误消息如下(抱歉这个巨大的消息,但它可能很重要):
soap:ReceiverSystem.Web.Services.Protocols.SoapException:服务器无法处理请求.---> System.Xml.XmlException:根级别的数据无效.1号线,在System.Xml.XmlTextReaderImpl.Throw(例外五)在System.Xml.XmlTextReaderImpl.Throw(字符串RES,字符串ARG)在System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()在System.Xml.XmlTextReaderImpl位置1. ParseDocumentContent()在System.Xml.XmlTextReaderImpl.Read()在System.Xml.XmlTextReader.Read()在System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()在System.Xml.XmlReader.MoveToContent()在System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()在System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()在System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()在System.Web.Services. Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage消息)在System.Web.Services.Protocols.SoapServerProtocol.Initialize()在System.Web.Services.Protocols.ServerProtocolFactory.Create(类型类型,HttpContext的上下文中,请求的HttpRequest,HttpResponse对象响应,布尔逻辑abortProcessing )---内部异常堆栈跟踪结束---
这是我的代码:
$('selector').autocomplete({
source: function(request, response) {
$.ajax({
url: "../WebService/Member.asmx",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "POST",
data: JSON.stringify({prefixText: request.term}),
success: function(data) {
alert('success');
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert('error');
}
})
},
minLength: 1,
select: function(event, ui) {
}
});
Run Code Online (Sandbox Code Playgroud)
我的webservice看起来像这样:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class Member : …Run Code Online (Sandbox Code Playgroud) 我想用 C# 中的正则表达式匹配一个字符串。字符串前面只能有零个或多个空格,不允许有其他字符。
有效的字符串是:
"> 5", " > 5"
Run Code Online (Sandbox Code Playgroud)
无效的字符串是:
"1 > 5", "1> 3", ">> 3"
Run Code Online (Sandbox Code Playgroud)
我现在有这个正则表达式:
"\s*> "
Run Code Online (Sandbox Code Playgroud)
我也试过"[\s*]> ","[\s]*> "但没有运气。
这似乎是一个简单的问题,但我对正则表达式很陌生,我没能在其他地方找到答案。
提前致谢!