[英]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.