1
While giving a View In Browser on my Webservice, brought me this message. It doesn’t look like a message that Webservice is all ok. What is this message?
Service
This is a Windows© Communication Foundation service.
Metadata publishing for this service is currently disabled.
If you have access to the service, you can enable metadata publishing by completing the following steps to modify your web or application configuration file:
1. Create the following service behavior configuration, or add the <serviceMetadata> element to an existing service behavior configuration:
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
2. Add the behavior configuration to the service:
<service name="MyNamespace.MyServiceType" behaviorConfiguration="MyServiceTypeBehaviors" >
Note: the service name must match the configuration name for the service implementation.
3. Add the following endpoint to your service configuration:
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
Note: your service must have an http base address to add this endpoint.
The following is an example service configuration file with metadata publishing enabled:
<configuration>
<system.serviceModel>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="MyNamespace.MyServiceType" behaviorConfiguration="MyServiceTypeBehaviors" >
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<!-- Add the following element to your service behavior configuration. -->
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
For more information on publishing metadata please see the following documentation: http://go.microsoft.com/fwlink/?LinkId=65455.
I’m crawling with WCF slow paces. I went to add a reference to my windows Forms project to consume the web service method and see what happened. I understood that REST does not add reference, right?
There was an error downloading 'http://localhost:4600/SuporteTecnicoService.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost:4600/SuporteTecnicoService.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4600/SuporteTecnicoService.svc. The client and service bindings may be mismatched.
The remote server returned an error: (415) Unsupported Media Type.
If the service is defined in the current solution, try building the solution and adding the service reference again.
In my Solution I have some projects. A class library project where I have a POCO class and an interface.
namespace V99SuporteTecnicoContracts
{
[Table(Name="T_PDV")]
[DataContract(Namespace="")]
public class TPDV
{
[Column]
[DataMember]
public int IDPdv { get; set; }
[Column]
[DataMember]
public string CNPJ { get; set; }
[Column]
[DataMember]
public string RazaoSocial { get; set; }
......
and my interface
namespace V99SuporteTecnicoContracts
{
[ServiceContract]
public interface ISuporteTecnicoContract
{
[OperationContract]
//[WebGet(UriTemplate = "/{_cnpj}")]
[WebInvoke(Method="POST", ResponseFormat=WebMessageFormat.Xml)]
TPDV getCnpjParceiro(string _cnpj);
}
}
Well, I also have the svc itself. Below his source
namespace SuporteTecnicoService
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SuporteTecnico : ISuporteTecnicoContract
{
public TPDV getCnpjParceiro(string _cnpj)
{
V99_WEB_QAEntities db = new V99_WEB_QAEntities();
TPDV pdv = new TPDV();
List<string> lista = new List<string>();
//DataContext contexto = new DataContext();
var resultado = (from _lista in db.T_PDV
where _lista.CNPJ == _cnpj
select new { _lista.CNPJ, _lista.RazaoSocial, _lista.Endereco}).ToList();
foreach (var lis in resultado)
{
pdv.CNPJ = lis.CNPJ;
pdv.RazaoSocial = lis.RazaoSocial;
pdv.Endereco = lis.Endereco;
}
return pdv;
}
}
}
and the service web.config(. SVC)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="V99_QAEntities" connectionString="metadata=res://*/Models.V99.csdl|res://*/Models.V99.ssdl|res://*/Models.V99.msl;provider=System.Data.SqlClient;provider connection string="data source=54.187.114.104;initial catalog=V99;persist security info=True;user id=V99App;password=V99@1032ab;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="V99_WEB_QAEntities" connectionString="metadata=res://*/Models.V99_Web.csdl|res://*/Models.V99_Web.ssdl|res://*/Models.V99_Web.msl;provider=System.Data.SqlClient;provider connection string="data source=54.187.114.104;initial catalog=V99_WEB;persist security info=True;user id=V99App;password=V99@1032ab;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="V99_OLAP_QAEntities" connectionString="metadata=res://*/Models.V99_Olap.csdl|res://*/Models.V99_Olap.ssdl|res://*/Models.V99_Olap.msl;provider=System.Data.SqlClient;provider connection string="data source=54.187.114.104;initial catalog=V99_OLAP;persist security info=True;user id=V99App;password=V99@1032ab;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service name="SuporteTecnico">
<endpoint address="" binding="webHttpBinding" contract="V99SuporteTecnicoContracts.ISuporteTecnicoContract" behaviorConfiguration="WebBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!--To avoid disclosing metadata information, set the values below to false before deployment-->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
When I try to use WCF Client, it does not provide me with the field for entering my cnpj parameter. I believe there is "ox on the line" of the web.config.
My new service.model tag on the web.config.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!--To avoid disclosing metadata information, set the values below to false before deployment-->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I made changes in my App.config and it was like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TesteWebService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISuporteTecnicoContract" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4600/SuporteTecnicoService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISuporteTecnicoContract"
contract="SuporteTecnicoContractClient.ISuporteTecnicoContract"
name="BasicHttpBinding_ISuporteTecnicoContract" />
<endpoint address="http://localhost:4600/SuporteTecnicoService.svc"
binding="webHttpBinding"
contract="V99SuporteTecnicoContracts.ISuporteTecnicoContract"
behaviorConfiguration="WebBehavior"
name="BasicHttpBinding_ISuporteTecnicoContract" />
</client>
</system.serviceModel>
<applicationSettings>
<TesteWebService.Properties.Settings>
<setting name="TesteWebService_ServiceSuporteTecnico_SuporteTecnico"
serializeAs="String">
<value>http://localhost:4600/SuporteTecnicoService.svc</value>
</setting>
</TesteWebService.Properties.Settings>
</applicationSettings>
</configuration>
The message has now changed. It’s a Runtime message and that’s the message:
The remote server returned an unexpected response:(400) bad request.
You can send a screenshot of your WCF Client? This is very mysterious... Here it worked so fast... :(
– carlosrafaelgn
I will send all my project. It has how to attach file here on the forum?
– pnet
Unfortunately, there is no such possibility.
– carlosrafaelgn