J'essaie de comprendre comment appeler un service WCF à partir d'un téléphone intelligent Windows. J'ai une application de console de smartphone très simple, qui ne fait que lancer et faire un appel au service. Le service renvoie simplement une chaîne. Je suis en mesure d'instancier la classe proxy, mais quand je l'appelle la méthode, il renvoie une exception:Impossible d'utiliser le service WCF à partir de Windows Mobile 5: aucun point de terminaison trouvé
Il n'y avait pas à l'écoute point final http://mypcname/Service1.svc/basic que pourrait accepter le message. C'est souvent causé par une adresse incorrecte ou une action SOAP. Voir InnerException, si présent, pour plus de détails.
L'exception intérieure:
Impossible d'établir la connexion au réseau .
J'ai essayé de suivre le tutoriel this sur la configuration des services avec Windows Mobile.
J'ai utilisé le NetCFSvcUtil pour créer les classes de proxy. J'ai le service s'exécutant sur IIS sur ma machine et l'Util utilisait le wsdl de cet endroit. J'ai créé une liaison HTTP de base comme suggéré dans l'article et je pense que j'ai pointé le proxy à l'URI correct.
Voici quelques sections de code pertinentes au cas où il serait utile de voir. Si quelqu'un a des suggestions, je l'apprécierais vraiment. Je ne suis pas sûr de quoi d'autre je peux piquer pour que cette chose fonctionne.
Merci!
Client (Program.cs):
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace WcfPoC
{
class Program
{
static void Main(string[] args)
{
try
{
Service1Client proxy = new Service1Client();
string test = proxy.GetData(5);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.InnerException.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}
extrait Proxy client (Service1.cs):
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class Service1Client : Microsoft.Tools.ServiceModel.CFClientBase<IService1>, IService1
{
//modified according to the walk thru linked above...
public static System.ServiceModel.EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("http://boston7/Service1.svc/basic");
/*
*a bunch of code create by the svc util - left unmodified
*/
}
Service (Service1.svc.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WcfService1
{
// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
public class Service1 : IService1
{
public string GetData(int value) //i'm calling this one...
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
}
Service Interface (IService1.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WcfService1
{
// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value); //this is the call im using...
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
/*
* ommitted - not using this type anyway...
*/
}
}
extrait web.config:
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://boston7/" />
</baseAddresses>
</host>
</service>
</services>
Hey Brian, avez-vous déjà fait travailler la WCF sur ces éléments: censuré: les appareils mobiles? – jp2code