Hello,
I am new to WCF and I am trying to create a Windows Phone 7 app which calls a self hosted WCF service. I have created WCF service hosted in a console app. I am unable to call the service from Windows 7 app running in emulator, but I am able to call it from another client console application running on the same machine the WCF service. The service invocation code and WCF configuration files are similar for both the windows phone app and client console application.
Service Configuration
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="BusinessServices.ServiceA" behaviorConfiguration="serviceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://warp-core:8000"/>
</baseAddresses>
</host>
<endpoint address="ServiceA" contract="BusinessServiceContracts.IServiceA" binding="basicHttpBinding" />
<endpoint binding="mexHttpBinding" bindingConfiguration="" name="mex" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
In the Windows Phone 7 project I was able to add the Service reference and generate proxy classes to call the service.
Windows Phone Client Configuration
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceA" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
maxBufferSize="65536" maxReceivedMessageSize="65536" textEncoding="utf-8">
<security mode="None" />
</binding>
<binding name="basicHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://warp-core:8000/ServiceA" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IServiceA" contract="ServiceA.IServiceA"
name="BasicHttpBinding_IServiceA" />
</client>
</system.serviceModel>
</configuration>
From the Phone, If I try to invoke the service asynchronously as
IServiceA m_proxyA;
public MainPage()
{
InitializeComponent();
m_proxyA = new ServiceAClient();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
IAsyncResult result = m_proxyA.BeginOperation1(Operation1Callback, null);
}
public void Operation1Callback(IAsyncResult ar)
{
string result = m_proxyA.EndOperation1(ar);
}
I get ServerTooBusyException with message
The HTTP service located at http://warp-core:8000/ServiceA is too busy.
And If I try an alternate blocking approach to call the service as following, then the phone app hangs and the following method call never returns
private void button1_Click(object sender, RoutedEventArgs e)
{
IAsyncResult result = m_proxyA.BeginOperation1(null, null);
string output = m_proxyA.EndOperation1(result);
}
Both of the above code sample work if I try this from client console app.
Any ideas on what I could be missing here?