Hello,
I created a wcf service and a wcf client following the microsoft tutorial.
http://msdn.microsoft.com/es-es/library/ms734712.aspx
When I test the communication on the same machine, everything works fine, but when I run the server on a different machine (192.168.10.100) and the client from the machine (192.168.50.20) does not work.
I tried to run svcutil to create a new proxy and configuration file as follows:
svcutil.exe http://192.168.10.100:8000/WCFServicios/MiServicio /config:app.config /out:generatedProxy.cs /language:cs
but I get the following error:
Intentando descargar metadatos de 'http://192.168.10.100:8000/WCFServicios/MiServicio' con WS-Metadata Exchange o DISCO. Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, versión 4.0.30319.1] © Microsoft Corporation. Reservados todos los derechos. Error: No se pueden obtener metadatos de http://192.168.10.100:8000/WCFServicios/MiServicio
How I can do to make communication between services?
Greetings and thanks
Jean PaulPosted Nov 9, 2011, 12:36 PM
I cannot find a problem with your code.
Still you can try exposing the metadata through a new port.
1) Use port 80001 for the metadata like below:
smb.HttpGetEnabled = true;
smb.HttpGetUrl = new Uri("http://localhost:8001/WCFServicios/MiServicio");
2) Now you can try adding the reference from another machine.
Use Visual Studio Project>Add Service Reference option to add the service reference.
Now try connecting using the new url: http://ServiceIP:8001/WCFServicios/MiServicio
3) If still the problem persists, you can check the firewall on the service machine.
Open the firewall settings (firewall.cpl) and check the following options. (pls see the image)
Now you can retry the above 2 steps.
As i do not have a n/w I cannot test the code. :)
Good Luck Ahead!
Regards,
Jean Paul
nombre apellidosPosted Nov 9, 2011, 9:20 AM
the browser not says anything about then metadata is disabled.
I think the metadata is activated by code. This is the code of my service:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace Servicios.WCF
{
[ServiceContract(Namespace = "http://Servicios.WCF")]
public interface ICalculator
{
[OperationContract]
double Add(double n1, double n2);
}
public class CalculatorService : ICalculator
{
public double Add(double n1, double n2)
{
double result = n1 + n2;
Console.WriteLine("Received Add({0},{1})", n1, n2);
Console.WriteLine("Return: {0}", result);
return result;
}
}
class Program
{
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8000/WCFServicios/MiServicio");
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
selfHost.AddServiceEndpoint(typeof(ICalculator), new WSHttpBinding(), "CalculatorService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
selfHost.Open();
Console.WriteLine("El servicio está listo.");
Console.WriteLine("Pulsar
Console.WriteLine();
Console.ReadLine();
selfHost.Close();
}
catch (CommunicationException ce) //controlar la expecpción CommunicationException
{
Console.WriteLine("Ha ocurrido una excepción: {0}", ce.Message);
selfHost.Abort();
}
}
}
}
Jean PaulPosted Nov 9, 2011, 8:03 AM
From the error languate I predict that it is saying "Metadata publishing is disabled".
You can paste the "http://192.168.10.100:8000/WCFServicios/MiServicio" url in a browser and verify it. If the browser says "Metadata publishing is disabled", you need to add the metadata information in the config file.
To add the Metadata
Please refer the article: http://msdn.microsoft.com/en-us/library/ms734765.aspx
You have to add the following highlighted code in your config in the exact position.