as said in the subject, I get an error when calling my WCF service (which works well on the simulator).
Here is the creation of the client :
Code: Select all
class ServiceClientSingleton
{
private static ServiceClient _client;
static readonly object _lock = new object();
private static ServiceClient ServiceClientSingleton()
{
_client = new ServiceClient(new System.ServiceModel.BasicHttpBinding(),
new System.ServiceModel.EndpointAddress(new Uri(@"http://localhost:2457/Service.svc/Service.svc")));
return _client;
}
public static ServiceClient Client()
{
if (_client == null)
{
lock (_lock)
{
if (_client == null)
ServiceClientSingleton();
}
}
return _client;
}
}
-- By the way I don't know why I had to put this weird URL with /Service.svc/Service.svc to make it work.. --
Here is how I call my webMethod :
Code: Select all
_listOfCategories = ServiceClientSingleton.Client().GetCategories().ToList();
And finally the code of the WebMethod :
Code: Select all
List<Categorie> IService.GetCategories()
{
List<Categorie> result = new List<Categorie>();
foreach (CATEGORIE DBCategorie in GetCategories())
{
result.Add(new Categorie { Code = DBCategorie.CATEGORIE_CODE, Libelle = DBCategorie.CATEGORIE_LIBELLE });
}
return result;
}
...
private List<CATEGORIE> GetCategories()
{
return Model.CATEGORIE.ToList();
}
CATEGORIE is in uppercase because it's a class generated by EntityFramework.
To be complete, my web.config (client):
Code: Select all
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2457/Service.svc/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="Service.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
Another thing to say is when I follow the tutorial making a global.asax file and putting the code to the "beginrequest" method, I get an error and my wcf test client refuse to work. So in server side I haven't any global.asax file.
What am I making wrong ?
Thanks in advance and good job for the new beta.