我一直在努力解决这个问题,在这个过程中学习很多关于绑定的东西.但有一件事让我感到困惑:各种链接(例如,参见这个或那个)明确说明"默认情况下,使用WsHttpBinding创建WCF项目",但这不是我所看到的.这就是我做的:
SOAP /发送请求到服务器:我得到错误
HTTP错误:无法在服务器'localhost'上发布'/WcfService7/Service1.svc'文件(415)
将soap数据发送到' http://localhost/WcfService7/Service1.svc '时出错HTTP错误:无法在服务器'10 .51.0.108上发布文件'/WcfService7/Service1.svc'(415)
有什么解释吗?谢谢
我正在开发一个必须支持向后兼容性的客户端 - 服务器应用程序(.NET 4 WPF,WCF).换句话说,就操作合同和数据合同而言,旧客户端应与新服务器兼容(反之亦然).
我们的WCF服务托管在IIS中,他们被设置为使用basicHttpBinding的:
<basicHttpBinding>
<binding name="basicHttpBinding_Configuration" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
...
<service behaviorConfiguration="SampleGateway.Data.DataAccessBehavior"
name="SampleGateway.Data.DataAccess">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_Configuration"
contract="Sample.Data.IDataAccess" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/SampleGateway/SampleGateway.Data.DataAccess.svc" />
</baseAddresses>
</host>
</service>
...
<behavior name="SampleGateway.Data.DataAccessBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
Run Code Online (Sandbox Code Playgroud)
假设合同非常基本,看起来像这样:
[ServiceContract]
public interface IDataAccess
{
[OperationContract]
List<Data> GetData(List<int> ids, DateTime startDateTime, DateTime endDateTime);
}
Run Code Online (Sandbox Code Playgroud)
最近,我发现我们可以将编码从更改XML为binary.结合IIS压缩,这确实提高了我们的WCF方法的性能,例如上面列出的GetData.
此编码更改还需要更改客户端和服务器WCF绑定,从a切换 …
我有以下对象:
public partial class Game
{
public bool Finished { get; set; }
public Guid GameGUID { get; set; }
public long GameID { get; set; }
public bool GameSetup { get; set; }
public Nullable<int> MaximumCardsInDeck { get; set; }
public Player Player { get; set; }
public Player Player1 { get; set; }
public bool Player1Connected { get; set; }
public bool Player1EnvironmentSetup { get; set; }
public long Player1ID { get; set; }
public int Player1Won { …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个需要与互联网上的Web服务进行通信的应用程序.Internet Explorer直到知道通过代理服务器连接到Internet的唯一应用程序.
代理设置设置为"使用自动配置脚本".
我保留了默认设置
<binding useDefaultWebProxy="true" />
Run Code Online (Sandbox Code Playgroud)
另外设置
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
Run Code Online (Sandbox Code Playgroud)
但没有运气.我一直在"(407)需要代理身份验证".
我做了一些谷歌,但解决方案似乎不适合我的情况.
简短更新:应用程序应使用默认用户凭据运行,并通过NTLM使用这些凭据对代理进行身份验证.但即使我设置客户端这样做,它似乎没有帮助.
我知道这已被多次询问,并且多次回答,但是,所有提供的应该使用的样本似乎并不想今天为我工作.
当我尝试启动主机时,我不断收到以下错误:
"在服务TraceService实现的合同列表中找不到合同名称'IMetadataExchange'.将ServiceMetadataBehavior直接添加到配置文件或ServiceHost以支持此合同."
根据Microsoft的示例,我的服务托管在托管的Windows服务主机中:http://msdn.microsoft.com/en-us/library/ms733069%28v=vs.90%29.aspx
这是我的简单配置:
<system.serviceModel>
<services>
<service name="Daff.Lae.Service.TraceService">
<endpoint address="" binding="wsHttpBinding" name="TraceService" contract="Contracts.Service.ITraceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/TraceService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
当然,如果删除此行,则没有错误时问题会变得更有趣:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常非常感谢:)
我们有一些安装WCF服务的MSI包(由WIX生成).这些服务中的大多数都需要net.tcp来进行端点绑定.
我想让我们的部署更轻松,并自动完成添加net.tcp的过程.我已经知道WixIisExtension.dll并使用它的有用功能(创建网站,virt.目录等).
我可以使用WixIisExtension来启用net.tcp协议吗?如果没有,我怎么能实现呢?
我有一个简单的WCF服务,在我的开发机器上进行测试时工作正常.
现在我已将Web服务移动到Web服务器,并且我正在http://mydomain.com:8005上运行该服务(在调试模式下).打开Web浏览器到该URL显示预期的服务页面,如果我在我正在调用的接口内的服务器上放置一个断点,它会命中断点并返回预期的数据......但是在客户端它返回出现以下错误:
收到http://mydomain.com:8005/的HTTP响应时发生错误.这可能是由于服务端点绑定不使用HTTP协议.这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭).请参阅服务器日志以获取更多详
更多线索:界面签名是:
IEnumerable<MyClass> GetThings(out string errMsg);
Run Code Online (Sandbox Code Playgroud)
where MyClass定义为Serializable,客户端和服务器之间的定义相同.
有什么想法我需要翻转什么秘密开关?
我有一个发现启用WCF服务,现在我想连接客户端.
问题:当我使用udp端点(1.)并尝试以编程方式发现服务时,它可以工作......当我使用App.config方法(2.)时它不会(错误:没有发现端点).
对我而言,两种解决方案的"udp发现结果"似乎应该相同,但遗憾的是它不是......
1.以编程方式处理(工作):
码:
DiscoveryClient discClient = new DiscoveryClient("udpDiscoveryEndpoint");
FindCriteria fCriteria = new FindCriteria(typeof(IAlarmServer));
fCriteria.Duration = TimeSpan.FromSeconds(5);
fCriteria.MaxResults = 1;
FindResponse fResponse = discClient.Find(fCriteria);
EndpointAddress address = fResponse.Endpoints[0].Address;
Console.WriteLine("Address found: " + address.ToString());
Run Code Online (Sandbox Code Playgroud)
配置:
<system.serviceModel>
<client>
<endpoint name="udpDiscoveryEndpoint" kind="udpDiscoveryEndpoint" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
2.使用App.config和"集成到端点"方法的方法(不起作用!):
码:
var Proxy = new AlarmServerClient("IAlarmServer"); // Default client generated by Visual Studio
Proxy.SomeMethod(); // throw no endpoints discovered exception
Run Code Online (Sandbox Code Playgroud)
配置:
<standardEndpoints>
<dynamicEndpoint>
<standardEndpoint name="discoveryDynamicEndpointConfiguration">
<discoveryClientSettings>
<findCriteria duration="00:00:05" maxResults="1">
<types>
<add name="AlarmServiceRef.IAlarmServer"/>
</types>
</findCriteria> …Run Code Online (Sandbox Code Playgroud) 如何在c#中以编程方式使用证书身份验证设置ServiceClient?
我不想使用.config.
using(var srv = GetServiceInstance())
{
srv.DoStuff()
}
private TheServiceClient GetServiceInstance()
{
var service = new TheServiceClient(CreateWsHttpBinding(), CreateEndpointAdress());
return service;
}
private static WSHttpBinding CreateWsHttpBinding()
{
var wsHttpBinding = new WSHttpBinding();
wsHttpBinding.Security.Mode = SecurityMode.Message;
wsHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
wsHttpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
wsHttpBinding.Security.Transport.Realm = "";
wsHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
wsHttpBinding.Security.Message.NegotiateServiceCredential = true;
wsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
wsHttpBinding.Name = "Bindingname";
wsHttpBinding.CloseTimeout = TimeSpan.FromMinutes(1);
wsHttpBinding.OpenTimeout = TimeSpan.FromMinutes(1);
wsHttpBinding.ReceiveTimeout = TimeSpan.FromMinutes(10);
wsHttpBinding.SendTimeout = TimeSpan.FromMinutes(1);
wsHttpBinding.BypassProxyOnLocal = false;
wsHttpBinding.TransactionFlow = false;
wsHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
wsHttpBinding.MaxBufferPoolSize = 524288; …Run Code Online (Sandbox Code Playgroud) 在尝试连接到Core Service时,出现以下错误:
客户端身份验证方案"Anonymous"禁止HTTP请求
Tridion环境使用SiteMinder中的SSO进行配置.
这是我的代码:
public static ICoreService2010 GetTridionClient()
{
var binding = new BasicHttpBinding()
{
Name = "BasicHttpBinding_TridionCoreService",
CloseTimeout = new TimeSpan(0, 1, 0),
OpenTimeout = new TimeSpan(0, 1, 0),
ReceiveTimeout = new TimeSpan(0, 10, 0),
SendTimeout = new TimeSpan(0, 1, 0),
AllowCookies = false,
BypassProxyOnLocal = false,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
MaxBufferSize = 4194304, // 4MB
MaxBufferPoolSize = 4194304,
MaxReceivedMessageSize = 4194304,
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = System.Text.Encoding.UTF8,
TransferMode = TransferMode.Buffered,
UseDefaultWebProxy = true,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{ …Run Code Online (Sandbox Code Playgroud) wcf-binding ×10
wcf ×9
c# ×6
.net ×4
.net-4.0 ×1
config ×1
endpoint ×1
iis-7.5 ×1
meta ×1
net.tcp ×1
performance ×1
tridion ×1
wcf-client ×1
wcf-security ×1
web-services ×1
wix ×1
wix3.5 ×1