我遇到了我编写的WCF应用程序的问题.
当客户端和服务器都在同一台机器上时运行正常,但是当我尝试在两台独立的机器上运行客户端和服务器时(因为它应该运行)我在异常中得到以下内容:
System.ServiceModel.EndpointNotFoundException:net.pipe://vm101.lab.foo.co.uk/VDNService上没有可以接受该消息的端点.这通常是由错误的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在).
System.IO.PipeException:在本地计算机上找不到管道端点'net.pipe://vm101.lab.foo.co.uk/VDNService'.
我不明白的是异常的第二行,它无法在我的本地机器上找到终点.终点是在另一台机器上,不是我的本地机器不是吗?
我使用的是网络命名管道绑定(NetNamedPipeBinding)而不是HTTP 绑定.
并且WCF代码是手工编码而不是生成(据我所知,这是常态,直到我编写应用程序之后才开始学习).
任何帮助,将不胜感激.
如何公开WCF服务,以便一个使用wsHttp绑定的客户端和另一个使用netTcp绑定的客户端都可以使用该服务?
我以编程方式设置wcf客户端参数,如下所示:
try
{
ServiceReference1.MyDbServiceClient webService =
new ServiceReference1.MyDbServiceClient(new System.ServiceModel.BasicHttpBinding(),
new System.ServiceModel.EndpointAddress((string)((App)Application.Current).Resources["wcfMyDBServiceEndPoint"]));
webService.GetSeriesImagesCompleted += new EventHandler<ServiceReference1.GetSeriesImagesCompletedEventArgs>(webService_GetSeriesImagesCompleted);
webService.GetSeriesImagesAsync(index);
}
Run Code Online (Sandbox Code Playgroud)
它适用于默认的maxBufferSize.但是,当客户端超过默认大小时,会出现例外情况:"已超出传入邮件的最大邮件大小限额(65536)."
如何在代码中设置此参数?谢谢.
我需要创建WCF应用程序,它将处理图片.它允许您将图片作为流获取,并将图片发送到服务器(作为流).它将在流传输模式下工作.目前我对这个选择犹豫不决.BasicHttpBinding还是NetTcpBinding?它们之间有什么区别?的优点和缺点.哪个更适合这个问题?
我有很多WCF服务,我需要从另一个服务中调用一个服务.我决定netNamedPipeBinding为此目的使用.
我的web.config文件看起来像这样.(我没有在这里复制不相关的东西.)
<services>
<service name="Services.AuthorizationService" >
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" >
<endpoint
name="AuthorizationService"
address=""
binding="basicHttpBinding" contract="ServiceContracts.IAuthorizationService" />
<endpoint address="net.pipe://localhost/TestSite/AuthorizationService.svc"
binding="netNamedPipeBinding" contract="ServiceContracts.IAuthorizationService"
name="AuthorizationNamedPipeEndpoint"/>
</service>
</Services>
Run Code Online (Sandbox Code Playgroud)
web.config文件中的客户端部分如下所示:
<client>
<endpoint address="net.pipe://localhost/TestSite/AuthorizationService.svc"
binding="netNamedPipeBinding" contract="ServiceContracts.IAuthorizationService" name="AuthorizationServiceNamedPipe" />
</client>
Run Code Online (Sandbox Code Playgroud)
我试图OperationContract像这样调用其中一个(GetDetails):
using (ChannelFactory<IAuthorizationService> authorizationChannel = new ChannelFactory<IAuthorizationService>("AuthorizationServiceNamedPipe"))
{
IAuthorizationService authorizationService = authorizationChannel.CreateChannel();
var response = authorizationService.GetDetails(new GetDetailsRequestMessage());
}
Run Code Online (Sandbox Code Playgroud)
当我执行此代码时,我在调用OperationContract GetDetails的行中得到异常:
在net.pipe://localhost/TestSite/AuthorizationService.svc上没有可以接受该消息的端点.这通常是由错误的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在).
我无法找出确切的问题.也没有InnerException.我使用的是Windows7机器,IIS版本是IIS7.5.请注意,我可以从我的Winform应用程序中调用此服务,没有任何问题.net.pipe绑定添加到IIS中的网站绑定.
如何使用net.pipe传输确保服务正常工作?在HTTP的情况下,我们可以在IE中浏览并确保它.
所以我对WCF并不过分熟悉,而且我用Google搜索的所有内容都没有帮助我如何实现我的需求.对不起,如果这是一个愚蠢的问题:)
基本上有一个服务器应用程序,其中包含使用WCF(net tcp绑定)公开的服务.我写了一个新的控制台应用程序,我需要调用该服务.所以我可以通过为我们拥有的代理项目添加一个dll并添加一堆配置文件(例如WCFClientBindings,WCFClientEndPoints)来实现这一点.如果我使用定义的终点,那么我可以调用这样的代码:
using (var partyProxy = new PartyControllerProxy())
{
// execute server method
partyProfile = partyProxy.GetLatestPartyProfile(context, parsedParameters.PartyId);
}
Run Code Online (Sandbox Code Playgroud)
但是应用程序应该能够调用作为命令行参数传入的主机名.
因此,虽然我的应用程序使用定义的端点:
<client>
<endpoint
name="IPartyControllerEndpoint"
address="net.tcp://localhost:46000/ServiceInterface/PartyController.svc"
binding="customBinding" bindingConfiguration="DefaultNetTcpBindingConfiguration"
contract="CompanyA.Service.Product.Core.Contracts.IPartyController"
behaviorConfiguration="DefaultEndpointBehavior">
</endpoint>
</client>
Run Code Online (Sandbox Code Playgroud)
我需要能够将localhost主机名更新为其他东西.我希望安全不会让我失望:)
我见过的例子似乎是通过传递"动态"绑定和地址来实例化客户端/代理,但我们的代理类不接受这些.在调用"代理"类之前,有没有办法更新端点的地址(在运行时)?我见过的唯一其他例子涉及实例化一个新的ServiceHost - 但这对客户来说听起来不太合适:)
谢谢!
编辑 -好的,这里的语法似乎很好用.这与我接受的答案有点不同,但这种方法是要走的路:)
using (ChannelFactory<IPartyController> factory = new ChannelFactory<IPartyController>("IPartyControllerEndpoint"))
{
EndpointAddress address = new EndpointAddress(String.Format("net.tcp://{0}/ServiceInterface/PartyController.svc", parsedParameters.HostName));
IPartyController channel = factory.CreateChannel(address);
partyProfile = channel.GetLatestPartyProfile(context, parsedParameters.PartyId);
((IClientChannel)channel).Close();
}
Run Code Online (Sandbox Code Playgroud) 我试图让第三方Java客户端与我编写的WCF服务进行通信.
收到消息时收到以下异常:
无法找到"System.IdentityModel.Tokens.UserNameSecurityToken"令牌类型的令牌身份验证器.根据当前的安全设置,不能接受该类型的令牌.
这是我的配置:
捆绑
<customBinding>
<binding name="TestSecureBinding">
<security authenticationMode="MutualCertificate" />
<textMessageEncoding messageVersion="Soap11WSAddressing10" />
<httpsTransport requireClientCertificate="true" maxReceivedMessageSize="5242880" />
</binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)
行为:
<serviceBehaviors>
<behavior name="TestCertificateBehavior">
<serviceCredentials>
<clientCertificate>
<certificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="Test 01"/>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine" revocationMode="NoCheck"/>
</clientCertificate>
<serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="Test 01"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)
终点:
<service name="TestService"
behaviorConfiguration="TestCertificateBehavior">
<endpoint
name="TestEndpoint"
address="https://localhost:443"
contract="TestServiceContract"
binding="customBinding"
bindingConfiguration="TestSecureBinding">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="https://localhost:443" />
</baseAddresses>
</host>
</service>
Run Code Online (Sandbox Code Playgroud)
有谁知道是什么原因造成的?
我目前正在使用Wcf应用程序并在跟踪日志中获得上面的mentiooned错误.
下面是Wcf服务的Web.Config.
<bindings>
<wsHttpBinding>
<binding name="NewBinding0" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession enabled="true" />
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
<service behaviorConfiguration="DBSyncWcfService.Service1Behavior" name="DBSyncWcfService.DBSyncService">
<endpoint binding="wsHttpBinding" bindingConfiguration="NewBinding0" name="ABC" contract="DBSyncWcfService.IDBSyncContract" address="http://192.168.5.170:9999/" />
<host>
<baseAddresses>
Run Code Online (Sandbox Code Playgroud)
以下是客户端配置.
WSHttpBinding binding = new WSHttpBinding();
//binding.ReaderQuotas.MaxArrayLength = 10485760;
//binding.MaxReceivedMessageSize = 10485760;
binding.Security.Mode = SecurityMode.None;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
binding.Security.Message.EstablishSecurityContext …Run Code Online (Sandbox Code Playgroud) 我是WCF的新手,并开始使用一个简单的无文件应用程序,其中一部分(web.config)可以在下面看到:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add
factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="./RelativeAddress.svc"
service="WCF_Transactions.MyService1"/>
</serviceActivations>
</serviceHostingEnvironment>
Run Code Online (Sandbox Code Playgroud)
现在我可以访问服务了
http://localhost:18148/RelativeAddress.svc
Run Code Online (Sandbox Code Playgroud)
然后我添加下一行:
<services>
<service name="WCF_Transactions.MyService1" behaviorConfiguration="MyBehavior1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:18148/" />
</baseAddresses>
</host>
<endpoint address="/RelativeAddressX.svc" binding="basicHttpBinding" contract="WCF_Transactions.IService1"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior1">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
所以我希望我的服务可以通过下一个地址访问:
http://localhost:18148/RelativeAddressX.svc
Run Code Online (Sandbox Code Playgroud)
但我不能这样做.我误解了什么?
我的控制台应用程序中有托管的WCF服务,如下所示:
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8080/Test");
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(TestService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("The Test service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost.
host.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
我在Windows应用商店(WinRT)应用程序中有一个客户端.我越来越
"(413请求实体太大"
当试图传递一个大字节数组.如何MaxReceivedMessageSize通过代码设置我的服务?