我们在Windows Server 2003上托管WCF Web服务.该服务器只有2个内部IP.我们希望从外部公开服务.这是通过将外部IP映射到服务的防火墙完成的.
因此,我需要修改服务以显示内部链接的外部IP.这不是问题,因为它只能在外部使用.
更改IIS中的主机标头值会从IIS发出"错误请求(无效主机名)"响应.我还在web.config中的端点条目中添加了一个"地址"值...但它只是指向内部机器名称.有任何想法吗?
编辑:我可以验证IIS7具有完全相同的行为.地址不起作用.不同的主机名给出了无效的主机名错误.有没有办法提出不同的(虚构的)IP?:/
EDIT2:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicAnonymous">
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Extended">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
</diagnostics>
<services>
<service behaviorConfiguration="Extended" name="AnCWCFWebService.ProductInfoProvider">
<endpoint address="" binding="basicHttpBinding" name="ASMX" bindingConfiguration="BasicAnonymous" contract="AnCWCFWebService.Interfaces.IProductInfoProvider"/>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 注意,WCF noobie 警报
我需要创建一个 WCF 客户端来查询非 WCF Web 服务。Web 服务不是 WCF 服务。此外,Web 服务需要客户端身份验证证书。现在,我有了证书,可以创建一个完美运行的非 WCF 客户端;我能够“添加 Web 引用”并打开一个证书对话框以允许我选择适当的证书,然后继续创建 Web 引用。尝试通过“添加服务引用”创建 WCF 客户端是另一回事,它只是因 403 拒绝访问错误而失败。
我有该服务的 WSDL,并已在其上运行 svcutil.exe,但我不确定如何从那里继续。
谢谢你的帮助!
我试图传输大约7000-8000个不大的对象(每个对象实例只有9个属性).有没有人知道为什么当我开始检索超过5000个对象时,我会收到连接错误?它完美运行,直到我达到数据大小的某个阈值.
我通过WCF的TCP服务绑定公开了这些对象的检索.我有以下示例配置:
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingConfig"
openTimeout="00:01:00"
sendTimeout="00:05:00"
closeTimeout="00:01:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security>
<transport/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="TestService">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="NetTcpBindingConfig"
contract="ServiceInterfaces.ITestService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8526/TestService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Services.ServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
从我的.NET代码中,我使用ChannelFactory调用该服务,其中包含以下示例代码:
using (ChannelFactory<ITestervice> channel = new ChannelFactory<ITestService>(BindingConfig, "net.tcp://localhost:8526/TestService"))
{
ITestService testService = channel.CreateChannel(); …Run Code Online (Sandbox Code Playgroud) 我有一个嵌入到Windows服务中的WCF服务.它绑定到localhost但它也接受来自这种URL的连接 - "http:// ip:port/ServiceName",如何将其隐藏起来并允许仅从localhost连接.
这是我的服务配置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Test.Service.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Test.Service.ServiceBehavior" name="Test.Service.TestService">
<endpoint address="localhost" binding="wsHttpBinding" contract="Test.Service.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/MyService/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 在网络驱动器上运行时,我们的C++解决方案(调用.NET 4.0程序集)存在一个奇怪的问题.该解决方案使用NetTcpBinding托管多个WCF服务,其中一个具有非默认绑定配置.在部分信任下,非默认的NetTcpBinding本身是不可能的(请参阅堆栈溢出问题WCF NetTcpBinding何时需要在客户端上完全信任?),但解决方案在完全受信任的网络驱动器下运行.这适用于几台不同的计算机(Windows Vista和Windows 7)但在一台计算机上失败(Windows Vista)并抛出异常,
为"system.serviceModel/bindings"创建配置节处理程序时发生错误:该程序集不允许部分信任的调用方.(K:\ Somepath\Testing.exe.Config第6行)
如果解决方案确实在该计算机上部分信任下运行,那么这个例外就完全可以了,但它确实在完全信任的情况下运行.即使我检查完全信任代码也是如此.
我们用其中一台计算机双重检查了互联网选项 - 没有差异.
所有DLL文件和EXE文件都是强名称.
更新:
网络驱动器在特定计算机上完全信任(caspol.exe).
我们应该寻找什么?
如果您需要其他信息,请告诉我们.
更新2: 我们仍然有这个问题,现在甚至在一台计算机上(Windows 7).所以它似乎与操作系统无关.
首先,我在WCF方面不擅长.我有一个在WindowsService中托管的WCF服务.从某个时候起,服务因异常而停止运行:
HTTP无法注册URL http:// +:8092/MyService /,因为另一个应用程序正在使用TCP端口8092.
有许多机器可以启动此服务,但最需要(客户)的机器不能.我在这个网站或其他任何地方看过很多帖子,但找不到解决方案.我从来没有看到像"它帮助我"这样的帖子.我已经好几天了,请帮忙.
在配置文件中的数据下面:
<system.serviceModel>
<services>
<service name="MyCompany.MyApp.MyAppService" behaviorConfiguration="MetadataSupport">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8092/MyAppService" />
<add baseAddress="net.tcp://localhost:8093/MyAppService" />
<add baseAddress="net.pipe://localhost/" />
</baseAddresses>
</host>
<endpoint binding="wsDualHttpBinding" contract="MyCompany.MyApp.IMyAppService" />
<endpoint binding="netTcpBinding" contract="MyCompany.MyApp.IMyAppService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="tcpmex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataSupport">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" httpGetUrl="" />
<!-- To receive …Run Code Online (Sandbox Code Playgroud) 我创建了2个不同的Web服务.其中一个是经典的Web服务和wcf Web服务,我也在IIS上托管它们.我通过STOPWATCH课程测试了性能.但经典的网络服务快2或3倍!你怎么看待这件事?我在谷歌搜索,我看到一篇文章说"WCF提供更好的性能,比ASP.NET Web服务快25% - 50%."
经典的网络服务
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public List < Customers>GetMyCustomers()
{
return new Customers().GetCustomers();
}
}
public class Customers
{
private int id { get; set; }
private string Name { get; set; }
private string SurName { get; set; }
public Customers()
{
}
public …Run Code Online (Sandbox Code Playgroud) 我有一个WCF的web服务我在我的本地机器上测试,它给了我一个headscratcher.
我的服务配置如下:
<system.serviceModel>
<services>
<service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService"
behaviorConfiguration="DatroseServiceBehavior">
<endpoint
address="mex"
binding="basicHttpBinding"
contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DatroseServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我的客户端配置如下:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDatroseService"
closeTimeout="00:02:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:02:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="524288" maxBufferPoolSize="524288"
maxReceivedMessageSize="524288"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas
maxDepth="32" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288"
maxNameTableCharCount="524288" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_IDatroseService"
address="http://localhost/DatroseWCFService/DatroseService.svc"
behaviorConfiguration="DatroseServiceBehavior"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IDatroseService" …Run Code Online (Sandbox Code Playgroud) 我有一个ComboBox看起来像这样的:
<ComboBox
ItemsSource="{Binding JobList}"
SelectedValue="{Binding Job,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
DisplayMemberPath="Title"
SelectedValuePath="Id"
IsEditable="True"
StaysOpenOnEdit="True"
/>
Run Code Online (Sandbox Code Playgroud)
它与 my 的绑定ViewModel如下所示:
public class ViewModel {
// this will fill from a database record for a person
public Job Job {
get { return _job; }
set {
if(value == _job) return;
_job = value;
OnPropertyChanged( () => Job );
}
}
// this will fill from all jobs records in database
public ObservableCollection<Job> JobList
{ /* do same as Job to implementing INotifyPropertyChanged …Run Code Online (Sandbox Code Playgroud) 我对 WCF 有点陌生,面临一些我无法在网上找到或被误解的问题。
<service name="Columba.Services.DataConnector.DataConnectorManager" behaviorConfiguration="ServiceBehavior">
<endpoint address="net.tcp://localhost:8888/IDataConnectorManager/" binding="netTcpBinding" contract="Columba.Services.Common.Contracts.DataConnector.IDataConnectorManager">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.msmq://./private/columba/IQueueItems" binding="netMsmqBinding" bindingConfiguration="MSMQBinding" contract="Columba.Services.Common.Contracts.Delivery.IQueueItems" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
Run Code Online (Sandbox Code Playgroud)
我想要实现的目标是将第二个端点的behaviorConfiguration =“ServiceBehavior”更改为不同的behaviorConfiguration(在serviceBehaviors标签中找到)。是否有可能实现这样的功能?!
新行为是配置 serviceCredentials 服务证书,但仅第二个端点需要它。
预先感谢各位。
wcf-binding ×10
wcf ×8
c# ×7
wcf-client ×2
web-services ×2
.net ×1
.net-4.0 ×1
asp.net ×1
combobox ×1
full-trust ×1
http ×1
iis-6 ×1
mvvm ×1
networking ×1
security ×1
service ×1
svc ×1
wpf ×1