我在服务器端使用此配置有一个wcf服务:
WSHttpBinding wshttp = new WSHttpBinding(SecurityMode.Message);
wshttp.ReceiveTimeout = new TimeSpan(0, 30, 0);
wshttp.MaxBufferPoolSize = 2147483647;
wshttp.MaxReceivedMessageSize = 2147483647;
wshttp.ReaderQuotas.MaxArrayLength = 2147483647;
wshttp.ReaderQuotas.MaxBytesPerRead = 2147483647;
wshttp.ReaderQuotas.MaxDepth = 2147483647;
wshttp.ReaderQuotas.MaxNameTableCharCount = 2147483647;
wshttp.ReaderQuotas.MaxStringContentLength = 2147483647;
wshttp.Security.Message.AlgorithmSuite =
System.ServiceModel.Security.SecurityAlgorithmSuite.Basic256Sha256Rsa15;
wshttp.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
CustomBinding cb = new CustomBinding(wshttp);
var clockSkew = new TimeSpan(2, 0, 0);
SymmetricSecurityBindingElement security =
cb.Elements.Find<SymmetricSecurityBindingElement>();
security.LocalClientSettings.MaxClockSkew = clockSkew;
security.LocalServiceSettings.MaxClockSkew = clockSkew;
// Get the
// System.ServiceModel.Security.Tokens
// .SecureConversationSecurityTokenParameters
SecureConversationSecurityTokenParameters secureTokenParams =
(SecureConversationSecurityTokenParameters)
security.ProtectionTokenParameters;
// From the collection, get the bootstrap element.
SecurityBindingElement bootstrap =
secureTokenParams.BootstrapSecurityBindingElement;
// Set the MaxClockSkew on the bootstrap element.
bootstrap.LocalClientSettings.MaxClockSkew = clockSkew;
bootstrap.LocalServiceSettings.MaxClockSkew = clockSkew;
EndpointAddress ea =
new EndpointAddress(
new Uri("http://localhost:80/MyService"),
System.ServiceModel.EndpointIdentity.CreateDnsIdentity(
"MyService Certeficate"));
isarService.AddServiceEndpoint(
typeof(ServiceLayer.IService),
cb,
new Uri("http://localhost:80/MyService")).Address = ea;
isarService.Open();
和一半配置在app文件中:
<system.serviceModel>
<bindings />
<client />
<services>
<service behaviorConfiguration="ServiceBehavior" name="SL.Service">
<endpoint address="mex" binding="
mexHttpBinding"
bindingConfiguration=""
name="MexHttpEndPoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/MyService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentInstances="100" />
<serviceCredentials>
<clientCertificate>
<authentication customCertificateValidatorType=""
certificateValidationMode="ChainTrust" />
</clientCertificate>
<serviceCertificate findValue="MyService Certeficate"
storeLocation="CurrentUser"
storeName="Root" x509FindType="FindByIssuerName" />
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="ServiceLayer.CUAPValidator,ServiceLayer" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我记录了我的客户端错误,他们发送日志文件给我修复他们的app.application工作为我的许多客户,但其中一些有这个错误:
System.ServiceModel.ProtocolException - &gt;从网络接收的XML存在问题。有关详细信息,请参阅内部异常。
System.Xml.XmlException - &gt;根级别的数据无效。第1行,第1位。
我不知道99客户端什么时候能正常使用这个配置,为什么其中3个有这个问题!
问题:
请帮助我以最简单的方式解决此问题。
信息:
我通过Windows服务托管我的服务。
编辑1:
我在客户端使用svc日志记录错误。然后我读错了,错误就是这样。在服务器端我没有看到日志中的错误。我不是什么完全不同,但似乎不同的是互联网连接,我的意思是代理服务器或VPN等。
编辑2:
.net版本会发生这种情况吗?因为版本4有一些更新。
编辑3:
看到这个错误与其他帮助
相同响应消息的内容类型text / html与绑定的内容类型(application / soap + xml; charset = utf-8)不匹配。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前1024个字节是:' 错误信息 一个 { FONT-WEIGHT:大胆; FONT-SIZE:10pt;颜色:#005a80; FONT-FAMILY:tahoma } 答:悬停{ FONT-WEIGHT:大胆; FONT-SIZE:10pt;颜色:#0d3372; FONT-FAMILY:tahoma } TD { FONT-SIZE:8pt; FONT-FAMILY:tahoma } TD.titleBorder { BORDER-RIGHT:#955319 1px solid; BORDER-TOP:#955319 1px solid; PADDING-LEFT:8px; FONT-WEIGHT:大胆; FONT-SIZE:12pt; VERTICAL-ALIGN:中间; BORDER-LEFT:#955319 0px solid;颜色:#955319; BORDER-BOTTOM:#955319 1px solid; FONT-FAMILY:tahoma;高度:35px;背景颜色:#d2b87a; TEXT-ALIGN:左 } TD.titleBorder_x { BORDER-RIGHT:#955319 0px solid; BORDER-TOP:#955319 1px solid; PADDING-LEFT:8px; FONT-WEIGHT:大胆; FONT-SIZE:12pt; VERTICAL-ALIGN:中间; BORDER-LEFT:#955319 1px solid;颜色:#978c79; BORDER-BOTTOM:#955319 1px solid; FONT-FAMILY:tahoma;高度:35px; BACKGR”。
AND内部错误:
远程服务器返回错误:(500)内部服务器错误。