我有一个包含过滤文本框和列表框的网页.对文本框的修改会触发AJAX请求,该请求返回一个值数组,用于填充列表框.
我有时会遇到这些调用失败的问题,这取决于返回的数据大小.小型返回数据将导致错误,返回大型数据并成功处理.
只有当我使用大于4.2的jQuery版本时才会出现此问题.如果我使用jQuery版本4.2,我没有问题.
jQuery.ajax(
{
cache: false,
url: "../Services/CmsWebService.svc/GetAvailableVideosForCompany",
type: "GET",
complete: function (jqXHR, textStatus) {
var responseText = jqXHR.responseText;
jQuery('#debugConsole').text(responseText);
availableVideosPopulationState.isRunning = false;
setTimeout(populateAvailableVideosListBox, 100);
},
data: { "companyIdString": queryParameters.companyIdField,
"textFilter": queryParameters.filterText
},
dataType: 'json',
error: function (jqXHR, textStatus, errorThrown) {
var errorString = 'Error thrown from ajax call: ' + textStatus + 'Error: ' + errorThrown;
alert(errorString);
},
success: function (data, textStatus, jqXHR) {
populateVideoListFromAjaxResults(data);
}
}
);
Run Code Online (Sandbox Code Playgroud)
如果返回两个元素,则以下是调试控制台的内容:
{"d":[{"__type":"ListEntry:#WebsitePresentationLayer","Text":"SOJACKACT0310DSN1.mpg - [SOJACKACT0310DSN1]","Value":"5565_5565"},{"__type":"ListEntry:#WebsitePresentationLayer","Text":"SOJACKACT0310DSN1Q.mpg - [SOJACKACT0310DSN1Q]","Value":"5566_5566"}]}
Run Code Online (Sandbox Code Playgroud)
但是如果返回一个元素:
{"d":[{"__type":"
Run Code Online (Sandbox Code Playgroud)
所以,当然,我们得到一个"未终止的字符串常量"错误. …
我正在尝试设置一个托管在IIS中的WCF服务,该服务公开了一个充当生成JSON数据的REST服务的端点,我想使用HTTPS.我想在UserNamePasswordValidator的帮助下自己处理用户身份验证,因为用户存储在数据库中.
目前我正在使用webhttpbinding来实现REST-fulness.当我尝试启用HTTPS(将安全模式设置为Transport)时,我的问题就出现了.我在服务器端有一个SSL证书(现在是自签名的),所以这一切都很好,但我不知道如何配置绑定的传输clientCredentialType,以便将凭据传递给我的UserNamePasswordValidator实现.
我google了很多,但似乎找不到任何好事.如果我理解正确IIS在WCF之前处理身份验证,并且没有任何关于它的事情?我真的不想使用ASP.Net会员提供商,但也许这是一种方法还是有另一种方式?
谢谢!
编辑:发现这个.不是我真正想要的......
我在我的一个WCF服务中遇到了一个奇怪的行为.这项服务工作良好约1.5年,但几周后它显示出某种"停电"(不幸的是我无法发布图像因为我是新来的).
虽然仍有来电,但来电/秒降至0."停电"总是15秒.在这15秒之后,处理排队的呼叫.它不能与网络相关,因为90%的呼叫来自同一服务器上的另一个WCF服务,并且没有其他服务(总共10个)受此行为的影响.服务本身确实继续工作,如计算内部资源,进行数据库更新等.不会增加内部工作的执行时间.这发生在大约18-25分钟,但停电总是15秒.
OS
Windows Server 2012
WCF作为Windows服务运行
WCF配置:
InstanceContextMode = InstanceContextMode.PerCall,
ConcurrencyMode = ConcurrencyMode.Multiple,
UseSynchronizationContext = false,
IncludeExceptionDetailInFaults = true
Binding = WebHttpBinding
并发节流设置:
MaxConcurrentCalls = 384,
MaxConcurrentInstances = 2784,
MaxConcurrentSessions = 2400
我已经做了一些调查:
我在服务发生的确切时间内完全转储了服务.ConcurrentCalls和ConcurrentSessions都没用完.转储没有显示可能导致问题的任何异常.
监控活动TCP连接远非其限制.
由于没有来电,甚至来自本地服务(使用localhost),我很确定它与网络无关.
低负载(见下文)和高负载(传入呼叫的5倍)会出现此问题.其频率不会根据负载而变化.我还尝试在我的登台系统上重现行为,每秒约600-1000次呼叫.我设法将服务带入一个状态,我发送更多来电/秒,因为服务可以处理.突出的电话增加了,在某些时候,服务当然崩溃了.但这种行为从未出现过.
当服务运行50个线程并且还有200个线程时,会出现此问题.虽然没有更多可用线程,但会出现错误消息.
我已经没有可能引起这种行为的事情了.我认为,它可能是GC阻塞线程,因为该服务在RAM中使用大约10GB.它是一种内存缓存服务.或者它可能是操作系统(Windows Server 2012)或与Windows服务本身相关的东西.
有没有人自己面对这样的事情,或者有人有另外的想法会导致什么?
编辑:现在我可以发布图片:

编辑: GC堆转储(感谢usr)

我看到近50%(总共70%,包括相关参考文献)是由一本大字典引起的.2700万条目(基于内存转储堆).我将专注于重构它.里面有很多未使用的物品.也许这会有所帮助.
另外,我将从msdn 添加GC.WaitForFullGCApproach方法,以查看当服务停止处理传入请求时GC是否正在运行.
当我知道更多时,我会告诉你.
编辑: GC统计(包括停电14秒)
•CLR Startup Flags: CONCURRENT_GC
•Total CPU Time: 42.662 msec
•Total GC CPU Time: 2.748 msec
•Total Allocs : …Run Code Online (Sandbox Code Playgroud) 我有一个 WCF 服务托管在 Windows 服务中。我已经向它添加了一个具有 webHttp 行为的 webHttpBinding,每当我向它发送 GET 请求时,我都会得到 http 200,这正是我想要的,问题是每当我向它发送 HEAD 请求时,我都会得到一个 http 405。
有没有办法让它也为 HEAD 返回 http 200?这甚至可能吗?
编辑:那是操作合同:
[OperationContract]
[WebGet(UriTemplate = "MyUri")]
Stream MyContract();
Run Code Online (Sandbox Code Playgroud) 我正在尝试在C#中使用Web服务。每当我尝试从Web服务类调用该函数时,都会收到“不理解SOAP标头操作”的信息。我在项目中添加了指向Web服务的Web参考[not service reference]。采取了以下步骤来添加Web参考
1)右键单击项目->添加WebReference
当我在Web浏览器中检查Web服务时,我在标题中找到了这个
<wsdl:definitions name="MyService" targetNamespace="http://tempuri.org/">
<wsp:Policy wsu:Id="WSHttpBinding_ICAIService_policy">
<wsp:ExactlyOne><wsp:All><sp:TransportBinding>
<wsp:Policy>
Run Code Online (Sandbox Code Playgroud)
我已完成以下代码来调用Web服务功能
WebStruct webS = new WebStruct();
webS.Name = "Peter";
webS.ID = 22;
webS.Find(webS);
Run Code Online (Sandbox Code Playgroud) 我在这里按照教程:http://allen-conway-dotnet.blogspot.co.uk/2012/07/using-basic-authentication-in-rest.html?_sm_au_ = iFVksVM0H8QrkntP,在WCF服务中实现用户身份验证但是我收到以下错误:
The authentication schemes configured on the host ('Anonymous') do not allow those configured
on the binding 'WebHttpBinding' ('Basic'). Please ensure that the SecurityMode is set to
Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the
authentication schemes for this application through the IIS management tool, through the
ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration
file at the element, by updating the ClientCredentialType property on the binding, or by
adjusting the AuthenticationScheme property … 我创建了一个Web服务,我试图为3个端点提供不同的绑定.1. basicHttpBinding,2.wsHttpBinding,3.webHttpBinding
当我进行服务引用时,我只获得了带有basicHttpBinding和wsHttpBinding绑定的端点.我没有得到webHttpBinding.什么可能是错的.
这是web.config中serviceModel节点的结构.
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<services>
<service behaviorConfiguration="VersionTolerance.Service1Behavior" name="BookShop.BookShopService">
<endpoint address="sadha" binding="basicHttpBinding" contract="BookShop.IBookShopService" />
<endpoint address="ws" binding="wsHttpBinding" contract="BookShop.IBookShopService" >
</endpoint>
<endpoint address="web" binding="webHttpBinding" behaviorConfiguration="webHttpBehavior"
contract="BookShop.IBookShopService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:49654/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VersionTolerance.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the …Run Code Online (Sandbox Code Playgroud) 我有一个WCF服务,使用它来公开端点webHttpBinding,并由WPF和ASP.NET应用程序使用.一切都很好.
我现在正试图从Windows Phone(WP7)中使用该服务.但是,由于.NET Framework还没有完全赶上WP7,因此System.ServiceModel.Web命名空间不可用,结果是webHttpBinding在WP7中不起作用.
现在,在我的服务上,如果我将其切换webHttpBinding为a basicHttpBinding,则手机应用程序可以运行.
我不想重写我的WPF和ASP.NET应用程序来使用basicHttpBinding它.
据我所知,WCF能够支持多个绑定,我试图配置和运行服务,从而可以显示端点都webHttpBinding和basicHttpBinding.该服务似乎启动良好.但是,WPF和ASP.NET应用程序无法访问它.当我尝试在WP7应用程序中创建服务引用时,我收到以下消息:
绑定实例已与侦听URI"http:// localhost:1726/GeneralService.svc"关联.如果两个端点想要共享相同的ListenUri,则它们还必须共享相同的绑定对象实例.两个冲突的端点要么在AddServiceEndpoint()调用中,在配置文件中指定,要么在AddServiceEndpoint()和config的组合中指定.
一位同事和我都打得四处多种变化的baseAddress,address以及listenUri没有任何的运气属性.我们现在正处于试验和错误的阶段,这并不是非常有效.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="generalBasic" />
</basicHttpBinding>
<webHttpBinding>
<binding name="general" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyProject.GeneralService"> …Run Code Online (Sandbox Code Playgroud) 我有一个基于AJAX的WebGet方法返回JSON.它不适用于几千行的JSON结果(如果我只使用100行左右).我注意到浏览器只是暂停而没有任何反应,没有任何显示Firebug控制台的信息:
[WebGet]
public HttpTransactionTransformArgs Test()
{
HttpTransactionFilterArgs args = new HttpTransactionFilterArgs();
args.Context = "MyDb";
args.Entity = "MyDbRow";
args.Key = "1";
args.Option = null;
HttpTransactionTransformArgs targs = new HttpDataPush().TransformRequest(args);
return targs;
}
[DataContract]
[KnownType(typeof(HttpTransactionTransformArgs))]
[KnownType(typeof(HttpColumnDefinition))]
[KnownType(typeof(HttpDataRow))]
public class HttpTransactionTransformArgs
{
[DataMember]
public string EntityName { get; set; }
[DataMember]
public List<HttpColumnDefinition> Schema { get; set; }
[DataMember]
public List<HttpDataRow> Data { get; set; }
[DataMember]
public bool TransactionSuccessful { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是WCF的服务器端配置:
<service name="Test.AJAXService" behaviorConfiguration="metadataBehavior">
<endpoint address="" behaviorConfiguration="Test.AJAXServiceAspNetAjaxBehavior"
bindingConfiguration="webHttpConfig" …Run Code Online (Sandbox Code Playgroud) 我有一个使用WebHttpBinding托管的WCF服务.服务非常简单,是一个接受多个参数的操作合同.使用"添加服务引用"后自动生成的我的WCF客户端无法直接使用WCF服务.该错误仅发生在WebHttpBinding而不是其他错误.
服务器端
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "Submit2String", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)]
string Submit2String(string input1, string input2);
Run Code Online (Sandbox Code Playgroud)
客户端
ExpenseServiceClient proxy = new ExpenseServiceClient();
proxy.Submit2String("test1", "test2");
Run Code Online (Sandbox Code Playgroud)
当我测试运行上面的代码时,我收到以下错误:
Error: InvalidOperationException was unhandled by user code
Manual addressing is enabled on this factory, so all messages sent must be pre-addressed.
Run Code Online (Sandbox Code Playgroud)
以下是使用"添加服务引用"后自动生成的配置文件的外观:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttp">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint binding="webHttpBinding"
bindingConfiguration="webHttp"
contract="ExpenseService.IExpenseService"
address="http://localhost/myservices/ExpenseService.svc">
</endpoint>
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) webhttpbinding ×10
wcf ×9
c# ×5
ajax ×2
json ×2
asmx ×1
gzip ×1
http ×1
https ×1
iis ×1
wcf-binding ×1
web-services ×1
webhttp ×1