I have a problem with connecting WCF Service and Windows Phone. I have a service with no source code (only publish on web) and I need to use it in Windows Phone 7 App.
I add a service reference in project, VS generated me file ServiceReferences.ClientConfig:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="HttpBinding_IWcfMobilServices">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.www.com/WcfMobilServices.svc"
binding="basicHttpBinding" bindingConfiguration="HttpBinding_IWcfMobilServices"
contract="MobileService.IWcfMobilServices" name="HttpBinding_IWcfMobilServices"></endpoint>
</client>
</system.serviceModel>
</configuration>
When i call a service method:
public static void Login()
{
var proxy = new MobileService.WcfMobilServicesClient();
proxy.LoginAsync("loginName", "paswword");
proxy.LoginCompleted += (s, a) =>
{
//some code
};
}
application in LoginCompleted throw me exception on a.Result :
System.ServiceModel.ProtocolException: Content Type text/xml; charset=utf-8 was not supported by service http://www.www.com/WcfMobilServices.svc. The client and service bindings may be mismatched. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<>c_DisplayClasse.b_d(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass1.b_0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at W7App.MobileService.LoginCompletedEventArgs.get_Result()} System.ServiceModel.CommunicationException {System.ServiceModel.ProtocolException}
Any idea what's wrong?
I tried to change the Binding in config file to wsHttpBinding, but VS shows me a warning:
The element 'bindings' has invalid child element 'wsHttpBinding'. List of Possible elements expected: 'basicHttpBinding, CustomBinding'.
Thanks