[英]strange WCF client side app.config generated
我是通过使用“添加服务引用”功能从VSTS2008(C#控制台应用程序,使用.Net 3.5)进行引用的,以添加对同一LAN中另一台计算机上IIS 7.0中托管的WCF服务的引用。 我发现自动生成的客户端app.config很奇怪。 这里是内容,
我的困惑是端点地址是“ http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo ”,但实际上它应该是“ http://labtest1/WcfDemo/service.svc ”(我可以使用IE中的http://labtest1/WcfDemo/service.svc ,以从WCF托管计算机labtest1获取WSDL)。 但是我无法通过使用地址“ http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo ”从IE获取WSDL。 机器labtest1的内部IP地址为10.10.200.10。 任何想法有什么问题吗?
顺便说一句:但是客户端功能起作用,即,对WCF端点方法的调用可以返回预期的结果。 “错误的”端点地址如何返回正确的结果?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IOrderManagement" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOrderManagement"
contract="ServiceReference1.IOrderManagement" name="BasicHttpBinding_IOrderManagement" />
</client>
</system.serviceModel>
</configuration>
编辑1:
这是我在IIS 7.0端使用的配置文件(web.config)。 我将service.svc放在计算机labtest1的默认网站(端口80)的WcfDemo子目录下。 我认为正确的终结点地址应为“ http://labtest1/WcfDemo/service.svc ”,而不是“ http://labtest1/WcfDemo/service.svc/10.10.200.10/wcfDemo ”?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="Foo.ServiceBehavior"
name="Foo.OrderManagement">
<endpoint address="" binding="basicHttpBinding" contract="Foo.IOrderManagement" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Foo.ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
您需要将两个URL分开:
这些可以不同! 仅仅因为您可以从http://labtest1/WcfDemo/service.svc
中检索WSDL,并不意味着该服务可在此处调用。
但是我同意-配置文件看起来很奇怪。...然后,“添加服务引用”功能并不因创建出色的配置而闻名。
我的建议:尝试使用WcfTestClient.exe(将在“程序文件\\ Microsoft Visual Studio 9.0 \\ Common7 \\ IDE”目录中找到)连接到服务,然后查看返回的内容。
要发现服务,您需要输入可在其中找到WSDL的地址-在您的情况下为http://labtest1/WcfDemo/service.svc
。 该测试客户端找到哪些端点?
渣
当WCF服务托管在域内的服务器上时,我已经看到了这种情况。 该实用程序似乎创建了一个Intranet URL,而不是一个Internet URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.