我有一个Silverlight客户端在IIS Web服务器上调用WCF服务.它使用默认的basicHttpBinding设置进行调用.我的客户端代码具有使用"更新服务引用"菜单选项时生成的常见Visual Studio生成的代理.
使用该代理对服务的每次调用都使用相同的连接吗?或者每次拨打电话时是否创建连接,然后在收到回复后将其关闭?由于客户端实际上通过HTTP进行SOAP调用,我只是假设每个服务请求都创建了一个新连接,但我想检查是否是这种情况?
(我需要知道,因为如果它每次创建一个新连接,那么每个请求都可能最终在不同的服务器上,因为有几个服务器负载均衡.它在代理的持续时间内使用单个连接然后我可以假设它们所有这些都最终在同一台机器上,因此缓存状态信息以获得更好的性能.)
我有一个通过wsHTTPBinding和basicHTTPBinding公开的WCF Web服务。后者将其端点地址指定为“ / basic”,如下所示:
<endpoint address="/basic" binding="basicHttpBinding" bindingConfiguration="theAwesomeBasicHttpServerBinding" contract="LOServices.Proxy.ServiceContracts.ILOService">
<identity>
<servicePrincipalName value="HTTP/MY_MACHINE_NAME" />
</identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)
绑定定义如下:
<basicHttpBinding>
<binding name="theAwesomeBasicHttpServerBinding" maxReceivedMessageSize="5000000">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用jquery调用其中一种web方法。由于这是通过basicHTTPBinding而不是RESTful进行的,因此,我将不使用JSON。因此,我正在通过wcf测试客户端对服务进行的先前(成功)调用构建请求XML:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ILOService/GetLoanActions</Action>
</s:Header>
<s:Body>
<GetLoanActions xmlns="http://tempuri.org/">
<request xmlns:d4p1="http://schemas.datacontract.org/2004/07/LOServices.Proxy.Requests" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:AssociationNumber>3</d4p1:AssociationNumber>
<d4p1:IgnoreWarnings>false</d4p1:IgnoreWarnings>
</request>
</GetLoanActions>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
因此,我正在使用的实际javascript的结构如下:
function callWs() {
var theRequest = " \
<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"> \
<s:Header> \
<Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/ILOService/GetLoanActions</Action> \
</s:Header> \
<s:Body> \
<GetLoanActions xmlns=\"http://tempuri.org/\"> \
<request xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/LOServices.Proxy.Requests\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"> \
<d4p1:AssociationNumber>3</d4p1:AssociationNumber> \
<d4p1:IgnoreWarnings>false</d4p1:IgnoreWarnings> …Run Code Online (Sandbox Code Playgroud) 我在使用以下函数创建System.ServiceModel.EndpointAddress连接到WCF服务时:
private static EndpointAddress GetEndPointAddress(string url, EndpointIdentity identity)
{
Uri baseAddress = new Uri(url);
EndpointAddress endpointAddress = new EndpointAddress(
baseAddress,
identity,
new AddressHeaderCollection());
return endpointAddress;
}
Run Code Online (Sandbox Code Playgroud)
我需要传入一个EndPointIdentity与我的web.config中的以下摘录相关的内容:
<identity>
<dns value="Some Value" />
</identity>
Run Code Online (Sandbox Code Playgroud)
我的WCF服务使用X509证书,因此我的身份似乎必须是类型X509CertificateEndpointIdentity.这个构造函数要求我传入证书...但我想传递一个dns值,如上所示.
任何人都可以建议我的方法有什么问题吗?
有人可以帮助netTcpBinding v/s BasicHttpBinding之间的主要区别是什么?
在我当前的项目中,我们将BasicHttpBinding转换为netTcpBinding并获得性能问题,即使BizTalk中的值设置为1:00:00,它也会启动超时.我们无法弄清楚为什么?