IMetadataExchange issue in WCF - c#

I am using VSTS 2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. I am following MSDN sample here without any modifications, http://msdn.microsoft.com/en-us/library/ms733766.aspx
When I open the service.svc file (in IIS manager, right click the svc file and select browse) in IIS, there is an error like this, any ideas what is wrong?
in the service list CalculatorService not find the protocol name "IMetadataExchange". Add ServiceMetadataBehavior to the configuration file or directly add to the ServiceHost
Here is the web.config I am using,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<!-- This section is optional with the default configuration
model introduced in .NET Framework 4 -->
<service name="Microsoft.ServiceModel.Samples.CalculatorService">
<!-- This endpoint is exposed at the base address provided by host: http://localhost/servicemodelsamples/service.svc -->
<endpoint address=""
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- The mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>

Can you please give some details about they way you have configured ur service.
http://msdn.microsoft.com/en-us/library/ms734765.aspx
This link has the steps. Point 5 and 6 should be of ur interest.
pavan
Try adding this to behavior to Config file:
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
and change the service element to ADD this behavior :
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
regards,
PAvan

Related

Succeed to connect my WCF service only from local machine unless machine ip address is specified instead of localhost

I have WCF service that clients connect to this service and do some operations.
This is my app.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WCFServiceHostingInWinService.MySampleWCFService">
<endpoint
name="ServiceHttpEndPoint"
address=""
binding="basicHttpBinding"
contract="WCFServiceHostingInWinService.IMySampleWCFService">
</endpoint>
<endpoint
name="ServiceMexEndPoint"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.192:8733/MySampleWCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This service installed on several machines but on each machine i need to change the <add baseAddress="http://192.168.0.192:8733/MySampleWCFService/" /> to the relevant IP address in order it to work, when specified localhost instead of Machine IP address i can connect to my service only from local machine.
Use 0.0.0.0 on base address, It should work for every network interface on system regardless of the address of it. localhost doesn't work because it call the DNS lookup, which evaluates to 127.0.0.1, that's serve only local.

There was no endpoint listening although there is no firewall running

I try to build an application to send messages between 2 machines usinf WCF according this article: http://www.youtube.com/watch?v=1-BYIQQYwjQ
After follow all the steps and when the server and the client runs on the same machine all works fine.
when moved my Client (simple console application) to another machine i have changed localhost from http://localhost:8733/MySampleWCFService/ to my machine IP address (both machines in the same network and there is no Firewall running but received the error
There was no endpoint listening
This is my App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WCFServiceHostingInWinService.MySampleWCFService">
<endpoint
name="ServiceHttpEndPoint"
address=""
binding="basicHttpBinding"
contract="WCFServiceHostingInWinService.IMySampleWCFService">
</endpoint>
<endpoint
name="ServiceMexEndPoint"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/MySampleWCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Maybe it could be an permissions issue ?

WCf REST service client side config file empty

I have a REST service and I have added it's reference in my WPF application. But as soon as I create a client of my proxy, it throws error and it throws error because my client side app.config is empty:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
This line on client throws error:
HelloWorldClient client = new HelloWorldClient();
This is my system.servicemodel section of web.config on the server side:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="WCFRestExample.HelloWorld">
<endpoint address="" binding="webHttpBinding" contract="WCFRestExample.IHelloWorld"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Can anybody tell me why is app.config empty? I have also restarted VS2010 but no luck.
NOTE: When I directly browse it in the browser the service is working. So, there is no problem with server side service.
Thanks in advance :)
As some other posts mentioned (such as After creating a wcf service how do I tell whether its restful or soap from the wsdl? and Create a WCF Proxy for a Rest Web Service, among others), Add Service Reference does not work for REST endpoints. You'll need to create the client yourself.
Another issue in your web.config: in order to create a REST endpoint, you need both to have the webHttpBinding (which you do) and add a <webHttp/> endpoint behavior to your endpoint (which you don't).

How to host Wcf service in IIS problem?

i have read more articles but i can nto host wcf service in IIS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfSrv.MyProject.GetTables.ServiceCrm">
<endpoint address="" binding="wsHttpBinding" contract="WcfSrv.MyTechnic.GetTables.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfSrv.MyProject.GetTables/ServiceTest/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
MyCodes:These code wcf service codes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data.Objects;
namespace WcfSrv.MyProject.GetTables
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class ServiceTest : IService
{
public List GetAllData(string CustomerName)
{
using (CrmEntities crmCtx = new CrmEntities())
{
return crmCtx.GetAllDataCustomer(CustomerName).ToList();
}
}
}
}
i try to host my Wcf service 192.168.0.218 i added Srv file and dll new virtual directory but i can not use wcf service.How to make it? i changed config file Best Regards...
Have you (re)installed basic asp integration on IIS using aspnet_regiis -i
(C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -i)
Since you don't specify the exact error it is hard to help, but the svc files need to be bound in IIS which rerunning the above statement usually resolves that problem.
WCF services hosted in IIS are represented as special content files (.svc files) inside the IIS application. See Hosting WCF Services in IIS section here how to use it and how to host you WCF service.

WSDL file is missing for WCF WebService

I created simple wcf service with default functionality and hosted in IIS7. Its working fine and rendering data to the client. But when I try to click on wsdl link in the service its showing "Page cannot be displayed".Let me know what will be the problem
.
When I try to click the link below (http://win-nsms.smsserver.com/VirtualFolder/MyService.svc?wsdl), WSDL file is not getting displayed in the browser. Instead I am getting "The page cannot be displayed" error in the page
Now If I change the "win-nsms.smsserver.com" to "localhost" in the URL, WSDL file is getting displayed.
Yes I added behaviour configuration in my config as follows
<system.serviceModel>
<services>
<service name="WcfServiceSample.Service1" behaviorConfiguration="WcfServiceSample.Service1Behavior">
<endpoint address="" binding="wsHttpBinding" contract="WcfServiceSample.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://win-nsms.smsserver.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceSample.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Have you allowed retrieval of service meta data?
In the behaviours section of your config file, add a new behaviour like this:
<behaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
Then tell your service to use this behaviour:
<system.serviceModel>
<services>
<service name="MyService"
behaviorConfiguration="HttpGetMetadata">
....
This is telling your service to allow the service metadata (the WSDL) to be retrieved via http. To confirm you can browse to the appropriate URL.
Is "mymachinename.domainname.com" added as a hostmask in IIS for the site?
You may need to setup the base address for the service.
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mymachinename.domainname.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
I had a similar problem where the service was working 100% for domain.com but not www.domain.com. I had to setup the latter as a redirect to the former and set the base address to the former.
HTH!
Did you enable WDS exposure? Standard settings dont show the WDSL.

Categories

Resources