I have a WCF rest web service. Everything works fine on my development environment (#develop using IIS express), but i get the following error on my production evironment:
Server Error in '/Services' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'inspectMessageBehavior' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.
Parameter name: element
Source Error:
Line 16: </service>
Line 17: </services>
Line 18: <behaviors>
Line 19: <endpointBehaviors>
Line 20: <behavior name="webHttp">
Source File: C:\Otimis\AdvLinkForWebService\services\web.config Line: 18
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
This is my web.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="AdvLinkForWebService.inbound">
<endpoint address=""
binding="webHttpBinding"
contract="AdvLinkForWebService.Iinbound"
behaviorConfiguration="defaultWebHttpBehavior"/>
</service>
<service name="AdvLinkForWebService.config">
<endpoint address=""
binding="webHttpBinding"
contract="AdvLinkForWebService.Iconfig"
behaviorConfiguration="webHttp"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
<behavior name="defaultWebHttpBehavior">
<inspectMessageBehavior/>
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="inspectMessageBehavior"
type="AdvLinkForWebService.MessageInspector.InspectMessageBehaviorExtension, AdvLinkForWebService"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
</configuration>
This question is related to this one
To run properly in my production evironment, it was necessary to specify the version, culture and key for inspectMessageBehavior. Ended up with the following configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="inspectMessageBehavior"
type="AdvLinkForWebService.MessageInspector.InspectMessageBehaviorExtension, AdvLinkForWebService, Version=1.0.5791.17758, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="defaultWebHttpBehavior">
<webHttp/>
<inspectMessageBehavior/>
</behavior>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="AdvLinkForWebService.inbound">
<endpoint address=""
binding="webHttpBinding"
contract="AdvLinkForWebService.Iinbound"
behaviorConfiguration="defaultWebHttpBehavior"/>
</service>
<service name="AdvLinkForWebService.config">
<endpoint address=""
binding="webHttpBinding"
contract="AdvLinkForWebService.Iconfig"
behaviorConfiguration="webHttp"/>
</service>
</services>
</system.serviceModel>
</configuration>
I don't know exactly how the version number is generated, even if it can be controlled, but I obtained it with the following command:
typeof(InspectMessageBehaviorExtension).AssemblyQualifiedName
Related
I have a WcfService hosted on Console Application on user(client) computer that provides access to document scanner device (Avision AD240) to scan documents and want to call this service from another website (e.g hosted on www.someotherdomain.com).
In summary: my website users work with jetScan document scanner and want to upload scanned images on the server in the website. I've done that in local IIS but I don't know how to address the local hosted service in the remote server hosted web application.
My WcfService Web.Config file looks like:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IScannerService" maxReceivedMessageSize="2147483647">
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<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>
<services>
<service name="WcfServiceScanner.ScannerService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IScannerService" contract="WcfServiceScanner.IScannerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfServiceScanner/WcfServiceScanner/" />
</baseAddresses>
</host>
</service>
</services>
<protocolMapping>
</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"/>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS" />
<add name="Access-Control-Max-Age" value="1728000" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
and a part of my remote server web application web.config file looks like :
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IScannerService" maxReceivedMessageSize="2147483647"/>
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IScannerService">
<security>
<transport sslProtocols="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/WcfService" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IScannerService" contract="WcfScannerService.IScannerService"
name="BasicHttpBinding_IScannerService" />
<endpoint address="net.tcp://localhost:8090/WcfService" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IScannerService" contract="WcfScannerService.IScannerService"
name="NetTcpBinding_IScannerService">
<identity>
<userPrincipalName value="DESKTOP-KILE609\Hosein" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The code is fine if it is locally accessible.
The following steps may help you:
Make sure the network is working on the other machine.
Check whether the IP address and port are occupied or shielded by the firewall.
Adding ?wsdl in the end of the url,if that works and show you an xml file, the service is reachable.
Thanks.
I've been tasked with updating an older WSE 3.0 amsx service with a newer WCF service, and it looks like I've got the signature/wsdl of the old service spoofed well enough but I can't seem to get the security configurations set in right.
I'm certainly no WSE wizard but I did find this wse3 policy file entry pertaining to the "Inquiry" service I'm updating:
<extensions>
<extension name="usernameOverTransportSecurity"
type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<extension name="requireActionHeader"
type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<extension name="mutualCertificate11Security" type="Microsoft.Web.Services3.Design.MutualCertificate11Assertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<extension name="x509" type="Microsoft.Web.Services3.Design.X509TokenProvider, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</extensions>
<policy name="Inquiry">
<usernameOverTransportSecurity />
<!--requireActionHeader /-->
</policy>
...
Based off of this msdn resource I should be able to use a custom binding to mimic the wse security, and here's my current web.config:
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="portName" type="CustomWsdlExtension.PortNameWsdlBehaviorExtension, TT_Demo3"/>
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="customPortName12">
<portName name="InquirySoap12"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="OnePointTwo">
<security authenticationMode="UserNameOverTransport" />
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service name="TT_Demo3.Inquiry">
<endpoint address=""
binding="customBinding"
bindingConfiguration="OnePointTwo"
contract="InquirySoap"
behaviorConfiguration="customPortName12"
name="InquirySoap12"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
The error I'm getting is Could not find a base address that matches scheme https for the endpoint with binding CustomBinding. Registered base address schemes are [http].
I've seen a lot of fixes for this type of issue to be adding a <security mode="transport" /> element to the binding but CustomBinding doesn't seem to support this.
Any ideas? Thanks in advance.
I have a MVC website and need a WCF service running to import data from an external source.
The service is located in a "Services" directory in the root of the application.
(http: //(Site name)/Services/Importer.svc - the contract is in the same folder)
It all works fine in my development environment, but the moment I publish it to the web server, it falls flat on its face with a 404 error.
I've found numerous posts of people having the same issues, but none of their solutions worked for me.
Here is my web.config:
<system.serviceModel>
<services>
<service name="APP_NAME.Services.Importer">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
contract="APP_NAME.Services.IImporter" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Any advice & guidance will be greatly appreciated.
I've spent hours trying to figure out this particular error and have had no luck.
I keep getting an error reading like I'm missing an endpoint and I'm new to WCF web Services so I'm not sure what direction to look. Anyway, The error reads.
Could not find default endpoint element that references contract 'ServiceReference1.ServiceContract' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
I create the object like this and then add a method.
ServiceReference1.ServiceContractClient test = new ServiceReference1.ServiceContractClient();
var connecting = test.Connect();
I have endpoints in my web.config file of the WcfProject. Here's my web.config
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<sessionState cookieless="false" mode="InProc"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="RestBinding"></binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfRestService1.Service">
<endpoint name="ServiceBinding" contract="WcfRestService1.IService" binding="webHttpBinding" bindingConfiguration="RestBinding" behaviorConfiguration="RestBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="basic" binding="wsHttpBinding" bindingConfiguration="" contract="WcfRestService1.IService" />
<host>
<baseAddresses>
<add baseAddress="http://servername/WcfRestService1/Service.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RestBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint name="Default"
address="http://servername/WcfRestService1/Service.svc"
binding="webHttpBinding"
bindingConfiguration="RestBinding"
behaviorConfiguration="RestBehavior"
contract="WcfRestService1.IService" />
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
I'm not sure what i need.
Thanks for any help.
You can not consume REST service using Service Proxy generated either by using Visual studio add service reference feature or using svcutil.exe. You need to use WebClient, HttpWebRequest or any other third party library capable of making http calls.
I have done following configuration inside configuration file for wsHttpBinding and with transport security. Meta data exchange, base address & bindings all are set for Https but it is still giving this issue.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WCFWindowsBasicHttpBinding.Service1Behavior" name="WCFWindowsBasicHttpBinding.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpEndpointBinding" name="WsHttpEndpoint" contract="WCFWindowsBasicHttpBinding.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="Mex" binding="mexHttpsBinding" contract="IMex"></endpoint>
<host>
<baseAddresses>
<add baseAddress="https://localhost/Service1.svc"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFWindowsBasicHttpBinding.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- 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>
Are you hosting the service on IIS? If so, make sure the WebSite you're deploying to has an SSL Binding defined in IIS.