好吧,我必须在这里遗漏一些完全简单的东西,因为我已经在谷歌上搜索了几天,在那里看了几十个答案,而且在这里,我无论如何都无法实现这一点.通过普通HTTP调用时,该服务工作正常.
这是我们的设置......我们有一个域名,http://www.mydomain.com.我们在该域上安装了SSL证书,就像我们保护电子商务网站一样.一切正常,我可以去http s://www.mydomain.com,它的工作正常.我在Windows Server 2003 R2上运行VS2008,.NET 3.5站点.
现在,我向我的站点添加了启用Silverlight的WCF服务,我希望通过SSL进行通信.如果我浏览到http s://www.mydomain.com/myservice.svc,它会向我显示WSDL描述性的" 您已创建服务 "页面,其中显示了使用
svcutil.exe https:// ...
Run Code Online (Sandbox Code Playgroud)
编辑:我意识到在wsdl文件中为svcutil显示的url实际上是指向Web服务器的物理盒名称,而不是正确的域.所以我完成了这篇博客文章中显示的步骤,使用adsutil脚本更新IIS中网站的SecureBinding.现在wsdl文件显示正确的SSL地址,但我仍然得到相同的错误.
现在我去试图挂钩我的Silverlight应用程序,它不起作用,在异步调用的结果中返回一个异常,说" 远程服务器返回错误:NotFound.我的一些博客阅读谈到通过创建测试Windows应用程序将其缩小到Silverlight问题,并试图从中引用它.好吧,我做到了,甚至在试图通过SSL访问服务的常规Windows应用程序中我得到一个例外说明:
System.ServiceModel.EndpointNotFoundException:
There was no endpoint listening at https://www.mydomain.com/mysubdir/myservice.svc that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. --->
System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Run Code Online (Sandbox Code Playgroud)
尽管我使用HTTPS方案明确地将服务引用添加到Windows应用程序,但它正确地获取了所有方法,并在编辑器中的Intellisense中显示它们.
请注意,这是一项不需要在用户身上显式登录的服务.我将在我的SOAP信封中发送自定义标头,以验证请求是否来自我们的应用程序,我只想让掠夺者嗅探线并挑出自定义标头.
现在到代码,我必须有一些愚蠢的小设置错误,因为从我读过的所有内容,这应该是一个相当简单的练习.
首先,我的服务的代码隐藏类使用以下属性进行修饰:
<ServiceBehavior(AddressFilterMode:=AddressFilterMode.Any)>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Run Code Online (Sandbox Code Playgroud)
我在服务器上的web.config的ServiceModel部分如下所示:
<system.serviceModel> …Run Code Online (Sandbox Code Playgroud) 我的第一个WCF示例正在运行.我有一个网站上的主机有很多绑定.因此,我已将此添加到我的web.config中.
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
Run Code Online (Sandbox Code Playgroud)
这是我的默认绑定http://id.web,它使用以下代码.
EchoServiceClient client = new EchoServiceClient();
litResponse.Text = client.SendEcho("Hello World");
client.Close();
Run Code Online (Sandbox Code Playgroud)
我现在正在尝试在运行时设置端点地址.即使它与上述代码的地址相同.
EchoServiceClient client = new EchoServiceClient();
client.Endpoint.Address = new EndpointAddress("http://id.web/Services/EchoService.svc");
litResponse.Text = client.SendEcho("Hello World");
client.Close();
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
The request for security token could not be satisfied because authentication failed.
Run Code Online (Sandbox Code Playgroud)
请建议我如何在运行时更改端点地址?
另外这里是我的客户配置,由Ladislav Mrnka提出要求
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IEchoService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None" /> …Run Code Online (Sandbox Code Playgroud) 我正在编写一个小的WCF/WPF应用程序来调整图像大小,但当我尝试从客户端向我的服务发送大小为28K的图像时,WCF让我感到悲伤.当我发送较小的图像时,该服务工作正常.我立即认为这是一个配置问题,我在网上搜索了关于绑定配置中MaxArrayLength属性的帖子.我已经在客户端和服务器上将这些设置的限制提高到最大值2147483647但仍然出现以下错误:
格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://mywebsite.com/services/servicecontracts/2009/01:OriginalImage时出错.InnerException消息是'反序列化System.Drawing.Image类型的对象时出错.读取XML数据时已超出最大数组长度配额(16384).可以通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性来增加此配额.有关更多详细信息,请参阅InnerException.
我已经使我的客户端和服务器配置相同,它们看起来如下:服务器:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:900/mex/"/>
<add baseAddress="net.tcp://localhost:9000/" />
</baseAddresses>
</host>
<endpoint binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
<endpoint address="mex" …Run Code Online (Sandbox Code Playgroud) 我注意到2147483647似乎是maxReceivedMessageSize的流行选择,但这是限制吗?
我似乎无法让我的WCF服务接受发送给它的大量数据.
我为客户端配置了maxReceivedMessageSize,可以很好地接收大数据,这不是问题.它正在向服务发送数据.
我试图配置服务,但没有运气.这是我的web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceDiscovery />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service.IService">
<clear />
<endpoint binding="basicHttpBinding" bindingConfiguration="MessageSizeBasic" contract="Service.IService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="MessageSizeBasic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="MessageSizeWeb" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</webHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我已按照SSL中的说明使用自托管WCF服务.当我尝试使用netsh在Windows 7上绑定证书时,如如何:使用SSL证书配置端口中所述.,它失败如下.
PS C:\> netsh http add sslcert ipport=0.0.0.0:8732 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-6677-8899-AABBCCDDEEFF}
Bad numeric constant: 224.
At line:1 char:104
+ netsh http add sslcert ipport=0.0.0.0:8732 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={001 <<<< 12233-4455-6677-8899-AABBCCDDEEFF}
+ CategoryInfo : ParserError: (224:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : BadNumericConstant
Run Code Online (Sandbox Code Playgroud)
C:\>netsh http add sslcert ipport=0.0.0.0:8732 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-6677-8899-AABBCCDDEEFF}
SSL Certificate add failed, Error: 1312
A specified logon session does not exist. It may already have been terminated.
Run Code Online (Sandbox Code Playgroud) 我已经和它斗争了好几天,实际上经历了一百篇文章,给出了如何在Web应用程序中设置基于WCF TCP的服务的部分指导.如果有人可以帮助我,我会将这个问题变成一个完整的指南.
当前状态
net.tcp连接适用于我的开发机器.它在部署到Windows Server 2008 R2后也可在本地运行.但是,它不能远程工作,即使可以远程telnet到服务器上的端口808.滚动到问题的底部以获取详细信息.如果可以的话请帮忙.
我将为此详细信息创建一个新问题,如果我从中得到结果,则用答案更新此问题.
码
我创建ServerHubService.svc了以下内容:
namespace Manage.SignalR
{
[ServiceContract]
public class ServerHubService
{
[OperationContract]
public void UpdateServerStatus(string serverStatus)
{
// Do something
}
}
}
Run Code Online (Sandbox Code Playgroud)
托管服务的应用程序的配置
在线教程之后,我在Web.config中添加了以下内容(我尝试了很多不同的变体).这是托管该服务的Web应用程序的Web.config,后来我想用TCP连接.
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServerHubBehavior"
name="Manage.SignalR.ServerHubService">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="portSharingBinding"
name="MyServiceEndpoint"
contract="Manage.SignalR.ServerHubService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
bindingConfiguration=""
name="MyServiceMexTcpBidingEndpoint"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://test.mydomain.com:808/SignalR/ServerHubService.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServerHubBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" /> …Run Code Online (Sandbox Code Playgroud) 我有一个wsf服务和一个客户端应用程序.在尝试与客户端和服务进行通信时,我收到了以下消息:
" 格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:blob时出错.InstallException消息是'反序列化FileBlob类型的对象时出错.读取XML数据时已超过最大数组长度配额(16384).可以通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxArrayLength属性来增加此配额.第1行,位置25931.'.请参阅InnerException了解更多详细信息. "
我有customBinding元素,它不允许我插入"readerQuotas"部分.在客户端和服务配置中,我有以下绑定元素:
<customBinding>
<binding name="LicenseServiceBinding"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
<security authenticationMode="UserNameOverTransport">
<localClientSettings maxClockSkew="00:07:00" />
<localServiceSettings maxClockSkew="00:07:00" />
</security>
<windowsStreamSecurity />
<httpsTransport maxReceivedMessageSize="2147483646"/>
</binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)
在此先感谢任何帮助:)
当我Eval.svc在Visual Studio 2012中右键单击并在浏览器中查看时,我得到以下内容 -
无法找到类型'EvalServiceLibary.Eval',作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供.
当我从测试客户端运行WCF服务时,一切正常.
评估服务:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class EvalService : IEvalService
{
Dictionary<string, JobPhaseTimer> jobTimers = new Dictionary<string, JobPhaseTimer>();
public void SubmitEntry(ENBO.Jobs.Job job, ENBO.Jobs.JobDetail jobDetail, ENBO.TimeLogs.TimeLog timeLog, ENBO.Users.User user, ENBO.Utilities.EntryType entryType, JobPhase jobPhase)
{
if (entryType == EntryType.Active)
{
JobPhaseTimer timer = new JobPhaseTimer();
timer.UID = job.ID + "_" + jobPhase.ID;
timer.JobID = job.ID;
timer.JobDetailID = jobDetail.ID;
timer.PhaseID = jobPhase.ID;
timer.StartTime = DateTime.Now;
timer.Stopwatch.Start();
jobTimers.Add(timer.UID, timer);
TimeLog log = new TimeLog();
log.JobID = job.ID; …Run Code Online (Sandbox Code Playgroud) 我对WCF Web服务的调用失败了 System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.
检查提琴手,我看到我正在发送:
内容长度:149839
超过65KB.
在服务器上启用WCF跟踪,我看到:
System.ServiceModel.ProtocolException:已超出传入邮件的最大邮件大小配额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.
添加此属性不能解决问题.
我已经尝试过这个属性,并且(稍后)与帖子建议的各种其他人一起尝试过.这是我目前(在服务器上):
<basicHttpBinding>
<binding name="PricerServiceSoap"
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)
我唯一的终点(下<client>)是:
<endpoint address="/NetPricingService/Service.asmx"
binding="basicHttpBinding" bindingConfiguration="PricerServiceSoap"
contract="Pricing.PricerService.PricerServiceSoap"
name="PricerServiceSoap" />
Run Code Online (Sandbox Code Playgroud)
我还补充说:
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
Run Code Online (Sandbox Code Playgroud)
在<behavior>.
我甚至跑(对于IIS 7):
%windir%\system32\inetsrv\appcmd set config "WebServicesDev/PricingService"
-section:requestFiltering -requestLimits.maxAllowedContentLength:104857600
-commitpath:apphost
Run Code Online (Sandbox Code Playgroud)
没有任何区别.
一个问题是,这是一个WCF服务,旨在取代旧的ASMX服务.服务框架是使用现有WSDL中的svcutil生成的.我无法更改客户端配置(客户端使用多种语言).我的测试客户端项目使用Add Web Reference(下Add Service Reference / Advanced)导入了该服务,因此我没有WCF配置.但是,如果我将它指向较旧的ASMX服务,则测试客户端可以正常工作.
我该如何修复或诊断?
附加信息 …
wcf-binding ×10
wcf ×9
c# ×4
.net ×1
.net-4.0 ×1
https ×1
iis ×1
net.tcp ×1
netsh ×1
readerquotas ×1
ssl ×1
wcf-client ×1
web-config ×1
windows-7 ×1