My problem is that when I run my solution, I had no problems
Here is what service output looks like
And when I make the my link to like this
And it is correct
But when I deploy the solution, install it using setup from the installer i created
I can still access, but output goes like this
And I try to navigate it, it looks like this and it is not right because it has no output
How can I fix it? I thought it is already ok because when I run it in visual studio it gives me expected output but when i deploy it is not.
Service App.Config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WcfServiceLibrary.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true"/>
</system.web>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior0">
<webHttp defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WcfServiceLibrary.Service">
<endpoint address="" behaviorConfiguration="NewBehavior0" binding="webHttpBinding"
bindingConfiguration="" name="Basic" contract="WcfServiceLibrary.IService" />
<host>
<baseAddresses>
<add baseAddress="http://PHWS13:8080/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
In the <behaviors> section you need to add
<serviceBehaviors>
<behavior name="NewSVCBehavior0"> >
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
And instead of
<service name="WcfServiceLibrary.Service">
write
<service name="WcfServiceLibrary.Service" behaviorConfiguration="NewSVCBehavior0">
and try after this change in config.
Related
I have created very simple ASP.NET web site with web service that is placed in an IIS application pool. Port and address are defined in the site settings of IIS. Web.config is very simple:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
It even does not have information regarding service.
I have looked at other samples of web.config and found them much more large:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="jsonHttp" />
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHttp"/>
</basicHttpBinding>
</bindings>
<services>
<service name="HelloDeviceCntrl.AaaComModule.AaaComModule">
<endpoint address="http://localhost:8001/json/Aaacom/" binding="webHttpBinding" bindingConfiguration="jsonHttp" contract="HelloDeviceCntrl.AaaComModule.IAaaComModule" behaviorConfiguration="JsonEndpointBehaviour"/>
<endpoint address="http://localhost:8001/basic/Aaacom/" binding="basicHttpBinding" behaviorConfiguration="DefaultEndpointBehaviour" contract="HelloDeviceCntrl.AaaComModule.IAaaComModule" />
</service>
<service name="HelloDeviceCntrl.BaaModule.BaaModule">
<endpoint address="http://localhost:8001/json/Baa/" binding="webHttpBinding" bindingConfiguration="jsonHttp" behaviorConfiguration="JsonEndpointBehaviour" contract="HelloDeviceCntrl.BaaModule.IBaaModule"/>
<endpoint address="http://localhost:8001/basic/Baa/" binding="basicHttpBinding" behaviorConfiguration="DefaultEndpointBehaviour" contract="HelloDeviceCntrl.BaaModule.IBaaModule"/>
</service>
<service name="HelloDeviceCntrl.ABCModule.ABCModule" behaviorConfiguration="ABCModuleServiceBehaviour">
<endpoint address="http://localhost:8001/json/ABC/" binding="webHttpBinding" bindingConfiguration="jsonHttp" contract="HelloDeviceCntrl.ABCModule.IABCModule" behaviorConfiguration="JsonEndpointBehaviour"/>
<endpoint address="http://localhost:8001/basic/ABC/" binding="basicHttpBinding" behaviorConfiguration="DefaultEndpointBehaviour" contract="HelloDeviceCntrl.ABCModule.IABCModule"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!--<serviceMetadata httpGetEnabled="true" />-->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="ABCModuleServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8001/ABC/get"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonEndpointBehaviour">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" faultExceptionEnabled="true" automaticFormatSelectionEnabled="true" />
</behavior>
<behavior name="DefaultEndpointBehaviour">
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<appBaa>
<add key="anykey1" value="anyvalue1" />
<add key="ClientBaaProvider.ServiceUri" value="" />
</appBaa>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
I got several questions while comparing both configs.
Why my config has no information about port and address? Can I manually add to web.config and overload existing value in site settings?
Should all these configuration lines be edited manually or appended according some project settings?
according to my knowledge,
some of the configuration are appended according to project settings,
and others, you add on your own.
if you want to a certian endpoint with a specific address and specific setings,
or if you want to have a signed or encrypted service.
IP address and port info (called site bindings) are controlled by IIS (or other web servers if you use them), so you won't see them in your web.config (and it is impossible to specify that either, as IIS won't allow you to do so at site or application level for such server level settings).
The sample file you pasted contains information about WCF settings, which is almost irrelevant for your case. Unless you know WCF very well, you should not interpret those settings in your own way and assume ASP.NET should behave the same. That's simply your misunderstanding and should be avoided in all cases.
My problem is with binding. It works when i run my client in debug mode but it doesn't work in release mode.
Server and client run on the same computer.
Unhandled Exception: System.ServiceModel.EndpointNotFoundException:
There was no endpoint listening at http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/ that
could accept the message. This is often caused by an incorrect address or SOAP
action. See InnerException, if present, for more details.
Server App.config:
<?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>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<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="ServiceLibrary.Service" behaviorConfiguration="metadataAndDebug">
<endpoint address="" binding="basicHttpBinding" contract="ServiceLibrary.IService">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/" />
</baseAddresses>
</host>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<!--
Step 2. Inside a <serviceBehaviors> section, add
a name attribute in the <behaviors> element that
matches the behaviorConfiguration attribute in the
<service> element above.
-->
<behavior name="metadataAndDebug">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" httpsGetEnabled="True" />
<!--
Step 3. Add a <serviceDebug> element and
modify the various attributes that suit your
scenario.
-->
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Client App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>
Any solution?
Like in this Question
I cant go on because of metadata.
It still doesnt work for me. I changed the localhost number
address="http://localhost:54786/AdventureWorksService/mex"
the rest I left how it was but it did not work... tryed it in APP.CONFIG or WEB.CONFIG... I tryed even with adding <system.serviceModel>...</system.serviceModel>
I still get the metadata error. Please help me with detailed solution if possible.
Here is the web.config
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime tar
getFramework="4.5" />
</system.web>
<connectionStrings>
<add name="AdventureWorks2012Entities" connectionString="metadata=res://*/AdventureWorksModel.csdl|res://*/AdventureWorksModel.ssdl|res://*/AdventureWorksModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\Projects;initial catalog=AdventureWorks2012;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" />
</system.webServer>
</configuration>
And here is the app.config
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<!--<system.serviceModel>-->
<services>
<service name="AdventureWorksService"
behaviorConfiguration="metadataSupport">
<endpoint
address="http://localhost:54786/AdventureWorksService/mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--</system.serviceModel>-->
</configuration>
Some missing information in the question, but I'll give it a guess.
You do not expose metadata, which in turn prevents you from adding a service reference. Doublecheck that you have the httpGetEnabled="true" in the configuration (web.config) for application that hosts the service. If you are using HTTPS, then switch the element with httpsGetEnabled="true". You can combine the two if needed.
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
EDIT: You would get a clear message stating this if you try to open the given service url in your browser.
EDIT2:
You need to include a service behavior, and the service endpoint with a contract. The name attribute refers to the service implementation. The namespace for the service, including the service name but without the .svc file extension. The contract attribute refers to the contract interface which that is also created when you choose new wcf service.
<system.serviceModel>
<services>
<service
name="MyApp.Services.MyService"
behaviorConfiguration="MyServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="MyApp.Services.IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" /> <!-- Set this to true to return exception details to the calling client. -->
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Try adding this configuration and edit the appropriate attributes, and then open the service in a web browser. The client should automatically get the app.config updated when you add the service through the Add Service Reference in Visual Studio.
i have been working with a web service and it was working just fine then i added
attribute in the behaviors section in both App.config & Web.config and it crashed
the error is *
WCF The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service
, below you find the xml code for my App.config for my service library .. under it you find the xml code for my web.config file for my website thanks in advance for your help :)
my App.config for my library
<?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>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</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="FluoraPinServiceLibrary.Service1">
<endpoint address="" binding="basicHttpBinding" contract="FluoraPinServiceLibrary.IFluoraPinServices">
<identity>
<dns value="192.168.1.3" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.1.3:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<!-- 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>
<behavior name="Throttled">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<!-- 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" />
<serviceThrottling
maxConcurrentCalls="4"
maxConcurrentSessions="4"
maxConcurrentInstances="4"
/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=""
/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
and that's the code for my Web.config file
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5.1" />
<httpRuntime enableVersionHeader="false" executionTimeout="72000" maxRequestLength="4096" minFreeThreads="72" minLocalRequestFreeThreads="88" useFullyQualifiedRedirectUrl="false" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<!-- 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>
<behavior name="Throttled">
<serviceThrottling
maxConcurrentCalls="4"
maxConcurrentSessions="4"
maxConcurrentInstances="4"
/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=""
/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Your default behavior has only serviceDebug tag. You need to add serviceMetadata tag.
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<!-- 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"/>
<serviceMetadata/>
</behavior>
You can find details here
To IMetadataExchange be findable, declare serviceMetadata:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
Just remove this line and it will works like a charm
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
Your default (unnamed) behaviour does not include a serviceMetadata tag. You should include it (copy it from the "Throttled" behaviour) or use your new behaviour for your service endpoints.
Thanks to stackoverflow (mostly), I have created a WCF service that is able to pull data from our ms sql database and relay it back in a json format. The service works as expected locally and on its home server within our network. However, I can't seem to access the service when outside the network.
Are there additional parameters needed in the code to accommodate being published over the web or is it possibly just a host setup and has nothing to do with WCF or the service?
The server is 2008 R2 & IIS 7.5 which is currently hosting a dozen or so of our websites. We have setup a port for the service as well.
This is the web.config file I am using:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="SrvcBehavior" name="Service.svc">
<endpoint address="JSON" behaviorConfiguration="JSONEndpointBehavior" binding="webHttpBinding" bindingConfiguration="" name="RESTEP" contract="Service.Isvc" />
<endpoint address="SOAP" binding="basicHttpBinding" name="Basic" contract="Service.Isvc" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="JSONEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SrvcBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<connectionStrings>
<add name="conn" connectionString="server=SERVER-DATABASE\SQL2005;database=myDatabase;uid=USERID;password=USERPASSWORD;" />
</connectionStrings>
</configuration>