WP7 アプリから独自の WCF サービスを使用しようとしています。
WCF サービスの構成ファイル
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<services>
<service name="mergedServices.MergedService">
<endpoint address="" binding="wsHttpBinding" contract="mergedServices.RelationGeneratorServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="mergedServices.keywordSearchServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="mergedServices.QAServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="mergedServices.CompareWithOnePredicateInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="mergedServices.ComparisonServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/mergedServices/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
コンソール クライアントで WCF サービスを参照すると、クライアントの構成ファイルは次のようになります。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_RelationGeneratorServiceInterface"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_keywordSearchServiceInterface" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_QAServiceInterface" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_CompareWithOnePredicateInterface"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_ComparisonServiceInterface" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/mergedServices/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_RelationGeneratorServiceInterface"
contract="ServiceReference1.RelationGeneratorServiceInterface"
name="WSHttpBinding_RelationGeneratorServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/mergedServices/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_keywordSearchServiceInterface"
contract="ServiceReference1.keywordSearchServiceInterface"
name="WSHttpBinding_keywordSearchServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/mergedServices/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_QAServiceInterface"
contract="ServiceReference1.QAServiceInterface" name="WSHttpBinding_QAServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/mergedServices/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_CompareWithOnePredicateInterface"
contract="ServiceReference1.CompareWithOnePredicateInterface"
name="WSHttpBinding_CompareWithOnePredicateInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/mergedServices/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ComparisonServiceInterface"
contract="ServiceReference1.ComparisonServiceInterface" name="WSHttpBinding_ComparisonServiceInterface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
問題は、WP7 プロジェクトから WCF サービスを使用しようとするときです。サービスを参照すると、構成ファイルの内容は次のようになります。
<configuration />
それだけです........そして、アプリを起動すると、次のランタイム エラーが表示されます。
System.Collections.Generic.KeyNotFoundException was unhandled
Message=KeyNotFoundException
StackTrace:
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(String key)
at System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Client()
at System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at MergedServicesConsumer.WeetitService.QAServiceInterfaceClient..ctor()
at MergedServicesConsumer.MainPage.button1_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
参照すると、バインド後に構成ファイルが返されるはずです。何が問題なのかわかりません。IIS で WCF をホストしていません。WP7 アプリの試用中にバックグラウンドで WCF ライブラリのプロジェクトを実行しているだけです。エミュレーター。