I have implemented a WCF service for connecting c# project with SAP.
But I receive the following error when I try to start the service. The error is as follows
The content type text/html; charset=iso-8859-1 of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml"). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 442 bytes of the response were:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode> soap:Server </faultcode>
<faultstring xml:lang="en"> RABAX occurred on server side </faultstring>
<detail>
<sap:Rabax xmlns:sap="http://www.sap.com/webas/710/soap/runtime/abap/fault/generic">
<SYDATUM>20170904</SYDATUM>
<SYUZEIT>152028</SYUZEIT>
<ERRORCODE>SYNTAX_ERROR</ERRORCODE>
</sap:Rabax>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The following is my IIS config file for the WCF Service.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<system.web>
<compilation targetFramework="4.5" />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehavior">
<clientCredentials>
<httpDigest impersonationLevel="None" />
</clientCredentials>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="CustomBinding_HTTP">
<binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="64" maxSessionSize="2147483647">
<readerQuotas maxDepth="300" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
</binding>
<binding name="bindingBAPI" receiveTimeout="00:10:00" sendTimeout="00:05:00">
<mtomMessageEncoding messageVersion="Soap11"></mtomMessageEncoding>
<httpTransport authenticationScheme="Basic" realm="SAP NetWeaver Application Server[SC3/900]"></httpTransport>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="my end point address" binding="customBinding" bindingConfiguration="bindingBAPI" contract="ServiceReferenceBAPI.z_bedmanagement" name="BAPIEndpoint" />
</client>
<services>
<service name="Cerner.BM.Outbound.Service.BM_OutboundService">
<endpoint address="" binding="customBinding" bindingConfiguration="CustomBinding_HTTP" name="BM_OutboundService" contract="Cerner.BM.Outbound.Service.IBM_OutboundService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<!-- Client and institution value for successful BAPI Connection. -->
<appSettings>
<add key="BAPI_Client" value="" />
<add key="BAPI_Institution" value="" />
<add key="BAPI_UserName" value=""/>
<add key="BAPI_Password" value=""/>
</appSettings>
</configuration>
Related
I am new to WCF and trying to troubleshoot an error. I have a WCF service running on a remote server and am receiving an error when another WCF service tries to call it running in my localhost.
The HTTP request to [url to the service] was aborted. This may be due to the local channel being closed while the request was still in progress. If this behavior is not desired, then update your code so that it does not close the channel while request operations are still in progress.
I tried looking at the activity in the Microsoft Service Trace Viewer and the first error received is:
Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found.
I can see the service is running, I can access it in the browser.
Can anyone help point me in the right direction of anything I can try? The service that I am trying to connect to is called LinkTable and I have added the relevant config files.
Client web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyService" />
<binding name="BasicHttpBinding_IKeyLinkage" closeTimeout="00:25:00"
openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<binding name="BasicHttpBinding_IMaintenance" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_L2" closeTimeout="00:25:00" openTimeout="00:02:00"
receiveTimeout="00:02:00" sendTimeout="00:02:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="wsHttpBinding_IProcessXML" closeTimeout="00:25:00"
openTimeout="00:02:00" receiveTimeout="00:02:00" sendTimeout="00:02:00"
maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http:/path/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="NotificationService.IMyService" name="BasicHttpBinding_IMyService" />
<endpoint address="http://path/Maintenance.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMaintenance"
contract="MaintenanceService.IMaintenance" name="BasicHttpBinding_IMaintenance" />
<endpoint address="http://path/Services/KeyLinkage.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IKeyLinkage"
contract="KeyLinkageService.IKeyLinkage" name="BasicHttpBinding_IKeyLinkage" />
<endpoint address="https://path/Services/LinkTableService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_L2"
contract="LinkTable_L2.ILinkTableService" name="WSHttpBinding_ILinkTableService" />
</client>
<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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="wsHttpBinding" scheme="http" bindingConfiguration="wsHttpBinding_IProcessXML"/>
</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>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add name="ServiceModelTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
<listeners>
<add name="ServiceModelTraceListener" />
</listeners>
</source>
<source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
<listeners>
<add name="ServiceModelTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="App_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" />
</sharedListeners>
</system.diagnostics>
</configuration>
Server web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
</system.web>
<system.serviceModel>
<client>
<endpoint address="http://path/Services/LinkTable.svc" binding="basicHttpBinding" bindingConfiguration="AppName_WCF_BasicHttpBinding" contract="LinkTableWCF.ILinkTable" name="BasicHttpBinding_ILinkTable" />
</client>
<services>
</service>
<service behaviorConfiguration="AppName_L2_WCF_Behavior" name="AppName_L2_WCF.Services.LinkTableService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="AppName_L2_WCF_wsHttpBinding" contract="AppName_L2_WCF.ServiceContracts.ILinkTableService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="AppName_WCF_BasicHttpBinding" maxBufferPoolSize="819200" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="AppName_L2_WCF_wsHttpBinding" maxBufferPoolSize="819200" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AppName_L2_WCF_Behavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="AppName_L2_WCF.Utils.ServiceAuthenticator, AppName_L2_WCF" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="wsHttpBinding" scheme="http" bindingConfiguration="AppName_L2_WCF_wsHttpBinding" />
</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>
I'm having an issue with quota when I try to get the content of a file through my web service. I'm using windows services to start and maintenant the connection.
Here below is the message I get:
System.ServiceModel.CommunicationException: 'Error in deserializing body of reply message for operation 'GetFileContent'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'
Here my config files:
Server WCF web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="behavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="behavior.ShipperServiceEndPointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="behavior" name="MonitoringServer.MonitoringService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpbinding"
contract="MonitoringServer.IMonitoringService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:54322/Monitoring" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcpbinding" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionProtocol="OleTransactions"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
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"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
The server Windows service app.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="behavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="behavior.ShipperServiceEndPointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MonitoringServer.MonitoringService" behaviorConfiguration="behavior">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpbinding" contract="MonitoringServer.IMonitoringService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:54322/Monitoring" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcpbinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" closeTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
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"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
Client A app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\dev\monitoring\monitoring_new\client\monitoringclient\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<appSettings>
<add key="WebServiceAddress" value="net.tcp://localhost:54322/Monitoring"/>
</appSettings>
<system.serviceModel>
<behaviors />
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMonitoringService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
hostNameComparisonMode="WeakWildcard" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
portSharingEnabled="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession enabled="true" />
<security mode="Message" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:54322/Monitoring" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMonitoringService" contract="MonitoringServiceReference.IMonitoringService"
name="NetTcpBinding_IMonitoringService">
<identity>
<userPrincipalName value="DEV-JC-18\panipro" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Client "B" app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="WebServiceAddress" value="net.tcp://localhost:54322/Monitoring"/>
</appSettings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMonitoringService" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:54322/Monitoring" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMonitoringService" contract="MonitoringServiceReference.IMonitoringService"
name="NetTcpBinding_IMonitoringService">
<identity>
<userPrincipalName value="DEV-JC-18\panipro" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Can someone just point out what I'm doing wrong ?
Thank's in advance.
I get
"There was no endpoint listening at https://localhost/BassCoastServices/GeneralUtilityService.svc that
could accept the message. This is often caused by an incorrect address
or SOAP action. See InnerException, if present, for more details."
when I call the GeneralUtilityService from the client side and
"There was no channel actively listening at 'https://laura-laptop/BassCoastServices/GeneralUtilityService.svc'.
This is often caused by an incorrect address URI. Ensure that the
address to which the message is sent matches an address on which a
service is listening."
shows up when I debug w3wp.
Is there some sort of tool I can use that will make sure a client and server config file line up?
If this is an easy fix, please see the below App and Web config files.
App.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Username" value="sampleuser"/>
<add key="Password" value="samplepassword"/>
<add key="basePath" value="C:\Temp"/>
</appSettings>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="standardBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" allowCookies="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="163840" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="01:00:00" enabled="false"/>
<security mode="TransportWithMessageCredential" >
<transport clientCredentialType="Certificate" proxyCredentialType="None" />
<message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCertificateBehavior">
<callbackDebug includeExceptionDetailInFaults="true"/>
<clientCredentials>
<clientCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
</clientCertificate>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://localhost/BassCoastServices/GeneralUtilityService.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="standardBinding" contract="Adapt.WCF.IGeneralUtilityService" name="IGeneralUtilityServiceEndPoint">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
<add key="DatabaseConnectionString" value="Data Source=(local)\SQL2014;Initial Catalog=XIVICProduction;User ID=sa;Password=sameplepassword;MultipleActiveResultSets=True"/>
<add key="LogFilePath" value="C:\inetpub\wwwroot\Xivic\BassCoastServices\Log\Log.txt"/>
<add key="AllowMissingExternalIDs" value="true"/>
<!--No need to change-->
<add key="LogFileTypeLevel" value="Error"/>
<add key="SqlServerDateTimeStyle" value="103"/>
<add key="DatabaseType" value="Sql"/>
<add key="EnforceSecurityAtBusinessRulesLayer" value="false"/>
<add key="DateComparisonInaccuracy" value="35000"/>
<add key="CacheAccessItemsAtBusinessLayer" value="true"/>
<add key="CacheRecordsAtDataLayer" value="true"/>
<add key="SesionTimeout" value="1440"/>
</appSettings>
<system.serviceModel>
<services>
<!-- ENDPOINTS -->
<service name="IGeneralUtilityServiceEndPoint" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="wsHttpBinding" contract="Adapt.WCF.IGeneralUtilityService" bindingConfiguration="wsHttpEndpointBinding"/>
</service>
</services>
<!-- BEHAVIOURS -->
<behaviors>
<serviceBehaviors>
<behavior name="UserNameBehaviour">
<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647" />
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Adapt.WCF.Security.CustomUserNameValidator, Adapt.WCF" />
<serviceCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
</serviceCertificate>
</serviceCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- BINDINGS -->
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "C:\inetpub\wwwroot\Xivic\BassCoastServices\Log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<!--startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
</startup-->
</configuration>
Calling WCF
_Channel = GetProxy<IGeneralUtilityService>();
_Channel.BeginTransaction(transactionId);
_Channel.CommitTransaction(transactionId);
public static T GetProxy<T>()
{
var channelFactory = new ChannelFactory<T>(string.Format("{0}EndPoint", typeof(T).Name));
channelFactory.Credentials.UserName.UserName = ConfigurationSettings.AppSettings["Username"];
channelFactory.Credentials.UserName.Password = ConfigurationSettings.AppSettings["Password"];
var workflowProxy = channelFactory.CreateChannel();
return workflowProxy;
}
Thanks in advance!
Update: I don't know what I did but now I'm getting
"Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost/BassCoastServices/GeneralUtilityService.svc. The client and service bindings may be mismatched."
Your problem is the way you create your channel factory. Some how it can not get the correct EndpointConfigurationName.
I'm not quite familiar on how to use only the EndpointConfigurationName as parameter in Channel Factory but you can try it this way:
var channelFactory = new ChannelFactory<T>("*", new EndpointAddress("https://localhost/BassCoastServices/GeneralUtilityService.svc"));
Well I don't know what the problem was but for anyone looking for a solution to this problem here are my web and app config files:
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!--Please configure-->
<!--Laura Local-->
<add key="DatabaseConnectionString" value="Data Source=(local)\SQL2014;Initial Catalog=XIVICProduction;User ID=sa;Password=samplepassword;MultipleActiveResultSets=True"/>
<!--No need to change-->
<add key="LogFilePath" value="C:\Temp\Log\log.txt" />
<add key="LogFileTypeLevel" value="Information" />
<add key="SqlServerDateTimeStyle" value="103" />
<add key="DatabaseType" value="Sql" />
<add key="EnforceSecurityAtBusinessRulesLayer" value="false" />
<add key="DateComparisonInaccuracy" value="35000" />
<add key="CacheAccessItemsAtBusinessLayer" value="true" />
<add key="CacheRecordsAtDataLayer" value="true" />
<!--Email Configuration-->
<!--add key="EmailAlertHost" value=""[INSERT="" HOST="" ADDRESS=""]/>
<add key="EmailAlertUsername" value=""[INSERT="" USERNAME=""]/>
<add key="EmailAlertPassword" value=""[INSERT="" PASSWORD=""] />
<add key="EmailAlertReplyToAddress" value=[INSERT REPLY TO ADDRESS] />
<add key="EmailAlertToAddress" value=""/>
<add key="EmailAlertCCAddress" value=""/>
<add key="EmailAlertSubject" value="*WARNING* - A Fatal Error Occurred # {0} - *WARNING*"/>
<add key="EmailAlertPriority" value="High"/-->
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<services>
<!--AssetInventoryService-->
<service name="Adapt.WCF.AssetInventory.AssetInventoryService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.AssetInventory.AssetInventoryService" bindingConfiguration="UserNameBinding" />
</service>
<!--AssetValuationUtilityService-->
<service name="Adapt.WCF.AssetValuation.AssetValuationUtilityService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.IAssetValuationUtilityService" bindingConfiguration="UserNameBinding" />
</service>
<!--CodeGenerationService-->
<service name="Adapt.WCF.CodeGeneration.CodeGenerationService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.CodeGeneration.CodeGenerationService" bindingConfiguration="UserNameBinding" />
</service>
<!--CodeUtilityService-->
<service name="Adapt.WCF.CodeGeneration.CodeUtilityService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.CodeGeneration.ICodeUtilityService" bindingConfiguration="UserNameBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/CodeUtilityService.svc" />
</baseAddresses>
</host>
</service>
<!--DataSchemaService-->
<service name="Adapt.WCF.DataSchema.DataSchemaService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.DataSchema.DataSchemaService" bindingConfiguration="UserNameBinding" />
</service>
<!--DataTransactionService-->
<service name="Adapt.WCF.DataTransaction.DataTransactionService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.DataTransaction.DataTransactionService" bindingConfiguration="UserNameBinding" />
</service>
<!--GeneralUtilityService-->
<service name="Adapt.WCF.GeneralUtilityService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.IGeneralUtilityService" bindingConfiguration="UserNameBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/GeneralUtilityService.svc" />
</baseAddresses>
</host>
</service>
<!--SecurityService-->
<service name="Adapt.WCF.Security.SecurityService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.Security.SecurityService" bindingConfiguration="UserNameBinding" />
</service>
<!--SyncService-->
<service name="Adapt.WCF.SyncService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.ISyncService" bindingConfiguration="UserNameBinding" />
</service>
<!--SystemSetupService-->
<service name="Adapt.WCF.SystemSetup.SystemSetupService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.SystemSetup.SystemSetupService" bindingConfiguration="UserNameBinding" />
</service>
<!--TaskManagementService-->
<service name="Adapt.WCF.TaskManagement.TaskManagementService" behaviorConfiguration="UserNameBehaviour">
<endpoint binding="customBinding" contract="Adapt.WCF.TaskManagement.TaskManagementService" bindingConfiguration="UserNameBinding" />
</service>
</services>
<!-- BEHAVIOURS -->
<behaviors>
<serviceBehaviors>
<behavior name="UserNameBehaviour">
<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647" />
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Adapt.WCF.Security.CustomUserNameValidator, Adapt.WCF" />
<serviceCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
</serviceCertificate>
</serviceCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- BINDINGS -->
<bindings>
<customBinding>
<binding name="UserNameBinding" closeTimeout="23:00:00" openTimeout="23:00:00" receiveTimeout="23:00:00" sendTimeout="23:00:00">
<security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
<secureConversationBootstrap authenticationMode="UserNameForSslNegotiated">
</secureConversationBootstrap>
</security>
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
<!--<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\temp\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>-->
</configuration>
App.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Username" value="dspec"/>
<add key="Password" value="samplepassword"/>
<add key="BasePath" value="c:\FileDrop"/>
</appSettings>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="standardBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" allowCookies="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="163840" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="01:00:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCertificateBehavior">
<callbackDebug includeExceptionDetailInFaults="true"/>
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="None"/>
</serviceCertificate>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/BassCoastServices/GeneralUtilityService.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="standardBinding" contract="Adapt.WCF.IGeneralUtilityService" name="IGeneralUtilityServiceEndPoint">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
I was digging a lot in stackoverflow.com to find answer for error: "HTTP request was forbidden by the client authentication scheme 'Anonymous", but none of proposed solutions solves my problem. So I decided to show my config files and ask about help.
I have WCF web service secured with SSL. All is fine until I started editin my WinForms Client which throws all the time error: "HTTP request was forbidden by the client authentication scheme 'Anonymous".
This is my WCF web service configuration file:
<?xml version="1.0" encoding="utf-8"?>
<bindings>
<wsHttpBinding>
<binding name="MBServiceBinding" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:05:00" sendTimeout="00:05:00" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SkillsAndTasks.CustomValidator, SkillsAndTasks"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="wsHttpBinding" scheme="https" bindingConfiguration="MBServiceBinding" />
</protocolMapping>
<services>
<service behaviorConfiguration="ServiceBehaviors" name="SkillsAndTasks.MBService">
<endpoint binding="wsHttpBinding" contract="SkillsAndTasks.IMBService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
And this is my WinForms App.config file:
<?xml version="1.0" encoding="utf-8" ?>
<applicationSettings>
<SkillsAndTasksDesktopClient.Properties.Settings>
<setting name="MBService" serializeAs="String">
<value>https://127.0.0.1/MBService.svc</value>
</setting>
<setting name="MBServiceLogin" serializeAs="String">
<value>ws1349</value>
</setting>
<setting name="MBServicePassword" serializeAs="String">
<value>qqlka123</value>
</setting>
</SkillsAndTasksDesktopClient.Properties.Settings>
</applicationSettings>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMBService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://127.0.0.1/MBService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IMBService" contract="MBService.IMBService"
name="WSHttpBinding_IMBService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</client>
</system.serviceModel>
Certainly I can preview web service in browser. I have binded my site with self-signed certificate (https) too.
I suspect that it must be something with security settings...
I have a Windows Service that hosts a WCF Service. I also have a client that connects to it and messages are sent back and forth. When I send a message from the client to the service the client catches the following excption:
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
This is a little odd because I am not expecting the service to reply directly to the message sent by the client. The service gets the message successfully, but then the client throws this exception and seems to lose its connection to the service.
Here is the Service app.config. Disregard the bit about RESTfull service:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="OSAERest.api" behaviorConfiguration="MyServiceBehavior">
<endpoint address="http://localhost:8732/api"
binding="webHttpBinding"
contract="OSAERest.IRestService"
behaviorConfiguration="WebHttp"/>
</service>
<service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WCFBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceTimeouts transactionTimeout="05:05:00" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500"
maxConcurrentInstances="2147483647" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebHttp">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsDualHttpBinding>
<binding name="WCFBinding">
<security mode="None">
</security>
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
</configuration>
And here is the client app.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ServiceIP" value="127.0.0.1"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00"
clientBaseAddress="http://localhost:8733/Design_Time_Addresses/WCF/WCFService/"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="None">
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Why is the client catching this exception?
EDIT:
Here is the C# code where I am sending the message to the service if that helps:
WCFServiceClient wcfObj;
EndpointAddress ep = new EndpointAddress("http://localhost:8731/Design_Time_Addresses/WCF/WCFService/");
InstanceContext context = new InstanceContext(this);
wcfObj = new Manager_WPF.WCFService.WCFServiceClient(context, "WSDualHttpBinding_IWCFService", ep);
wcfObj.Subscribe();
wcfObj.messageHost(message);
I've had the same problem with silverlight client and duplex tcp binding. The probem was caused by invoking callback to client right before returning from wcf method call. I've fixed this by putting callback invoke into background thread:
...
ThreadPool.QueueUserWorkItem(state =>
{
//this notifies service subscribers (calls registered callbacks)
OnConfigurationUpdated(EventArgs.Empty);
});
return;