我有一个wcf服务,并将其安装为windows服务。我可以从192.168.2.6机器访问这项服务:
"net.tcp://192.168.2.5:2025/Services/mex".我想使用静态ip和端口从另一台计算机访问此服务。
如何访问此服务?
我尝试连接net.tcp://staticIp:port/Services/mex,得到了错误:
Metadata contains a reference that cannot be resolved: 'net.tcp://[staticIP]:[port]/Services/mex'.If the service is defined in the current solution, try building the solution and adding the service reference again.(我把我的港口导航到2025年的内港)
我的配置:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IServices" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://192.168.2.5:2025/Services" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IServices" contract="myServices.IServices"
name="NetTcpBinding_IServices">
<!--<identity>
<dns value="localhost" />
</identity>-->
</endpoint>
</client>
<services>
<service name="F8ShadowWcfLib.Services">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="F8ShadowWcfLib.IServices">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://192.168.2.5:2025/Services" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
Edit1:
我从config中删除标记,并在运行时添加它。
myService.ServicesClient myServ = new myService.ServicesClient();
EndpointAddress myEndpointAdd = new EndpointAddress(new Uri("net.tcp://[staticIP]:[port]/Services") ,
EndpointIdentity.CreateDnsIdentity("net.tcp://f8srv.f8.com.tr:2299/Services"));myServ.Endpoint.Address = myEndpointAdd;
我遇到了不同的错误:服务器拒绝了客户端凭据。
发布于 2013-09-14 14:08:19
若要允许分离连接,请设置AddressFilterMode : Any,并同时设置服务和客户端。
这篇关于identy设置的文章:
http://msdn.microsoft.com/en-us/library/ms733130.aspx
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class Services : IServices
{
.
.
.
}发布于 2013-09-12 16:07:45
这个问题可能与这一部分有关:
<identity>
<dns value="localhost" />
</identity>这种工作是在本地工作的,因为本地主机在本地是有意义的,但在整个网络中却没有意义。
您可以通过多种方式验证此标识,例如指定运行服务的用户的UPN (用户主体名称)或运行该服务的服务器的SPN (Server主体名称)(尽管为此您必须注册一个SPN)。
这篇文章应该稍微解释一下:
http://msdn.microsoft.com/en-us/library/ms733130.aspx
https://stackoverflow.com/questions/18765713
复制相似问题