I'm trying to set up a WCF service with two endpoints which both expose the same service contract as follows
What I want to be exposed to clients...
http://server:1955/myService/secondEndpoint and
https://server:443/myService/
The issue appears to be with multiple base addresses.
If I explicitly specify the full address in each endpoint and omit the baseAddress section I get the following error
"When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://server:1955/myService/secondEndpoint'."
I therefore put relative address in the endpoint and add a base address
Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].
I feel like I am going in circles with this. Any help much appreciated.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfiguration"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport" >
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="ServiceBehavior" name="myService">
<endpoint address="nonsecure"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfiguration"
contract="ImyService"
name="myService" />
<endpoint address="https://server:443/myService.svc"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingConfiguration"
contract="ImyService"
name="myService" />
<host>
<baseAddresses>
<add baseAddress="http://server:1955/myService/" />
<add baseAddress="https://server:443/myService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Related
I have a simple WCF service that uses wsHttpBinding and works on Visual Studio development environment but not when deployed on IIS. My console client app that I use to test encounters the error: "The caller was not authenticated by the service" when I direct it to IIS endpoint where I deploy my service1.svc. I look on similar posting here in Stackoverflow but none works for me. I appreciate any advice from anyone.
My webconfig in IIS is as follows:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCFOA416_WSHttp.OA_Services">
<endpoint binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
name="WSHttp_OA_Server_Endpoint" contract="WSHttp_OA_ServerSoap" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="wsHttpBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
My client app.config is:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttp_OA_Server_Endpoint2" >
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://example.com/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint2"
contract="ServiceReference4.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint2">
<identity>
<servicePrincipalName value="host/AMAZONA-XXXXXX1" />
</identity>
</endpoint>
</client>
</system.serviceModel>
My client console code is:
ServiceReference4.WSHttp_OA_ServerSoapClient c1 = new ServiceReference4.WSHttp_OA_ServerSoapClient();
string[] a = c1.GetMethods();
foreach (string ss in a)
{
Console.WriteLine(ss);
}
My website setting for IIS Authentication is Anonymous.Authentication-Status is Enabled.
I got this working by setting the following:
Server web.config:
<wsHttpBinding>
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</wsHttpBinding>
Client app config:
<wsHttpBinding>
<binding name="WSHttp_OA_Server_Endpoint3">
<security mode="None" />
</binding>
</wsHttpBinding>
<endpoint address="http://ms.pwrmetrixonline.com/OA416WSHTTP/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint3"
contract="ServiceReference5.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint3" />
I have a windows application to send image to server using WCF service. When I run my code and upload an image, WCF returns "The remote server returned an error: (413) Request Entity Too Large."
I have tried several ways from links but not solved.
The following is my WCF Config.
<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>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.5.2" />
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
The following is app.config from Windows app.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILicencePhoto" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
<binding name="BasicHttpBinding_IUserLogging" >
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxxxx/wcf/image.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILicencePhoto"
contract="LicencePhoto.ILicencePhoto" name="BasicHttpBinding_ILicencePhoto" />
<endpoint address="https://xxxxx/wcf/user.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IUserLogging" contract="UserLogging.IUserLogging"
name="BasicHttpBinding_IUserLogging" />
</client>
</system.serviceModel>
I can log in with calling userWCF. The problem is when uploading user photo to WCF services. The user photo file size is only about 500KB max.
Thanks.
Nyi Nyi Aung
The main problem is that we don’t apply the configuration on the server-side. Since the server-side uses ProtocolMapping feature to enable the service works over HTTPS protocol, we should modify and apply the configuration on the BasicHttpsBinding instead of the BasicHttpBinding.
Please refer to the below configuration(Server-side).
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="httpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpsBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" bindingConfiguration="httpsBinding"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Feel free to let me know if the problem still exists.
I've read many posts about it but I don't know what happens with my web.config.
This is de web.config code:
<system.serviceModel>
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="Service.IService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" closeTimeout="00:05:00" openTimeout="00:05:00"
sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="NewBinding1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
I'm so sorry but I am not familiarized with the web.conf files. I've read that I have to set the maxReceivedMessageSize, but I've done it and I've received the same error.
I'm editing the file with Microsoft Service Configuration Editor.
I've tried with basicHttpBinding and without webHttpBinding, but does not work.
Every time I call the WCF, I receive the same error.
Trying in SOAPUI, when the message size is less than 65537, it works. When the message size is more than 65536, it does not work.
Thaks in advance.
Carles
Here is the working code of app.config-
<bindings>
<webHttpBinding>
<binding name="myBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed" >
<readerQuotas maxDepth="64" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ForecastREST_API.RESTServiceImplBehavior" name="ForecastREST_API.RestServiceImpl">
<endpoint address="http://localhost:59624/RestServiceImpl.svc" binding="webHttpBinding" contract="ForecastREST_API.IRestServiceImpl" behaviorConfiguration="Web" bindingConfiguration="myBinding">
</identity>
</endpoint>
<endpoint address="mex" binding="webHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Web">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
<dispatcherSynchronization asynchronousSendEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ForecastREST_API.RESTServiceImplBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
The maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" and the bindingConfiguration="myBinding" is important only in service endpoint section and the bindingName is needed also in my project.
I've referred to several stackoverflow threads on the above matter, but even after applying the solutions mentioned, I still get the same error.
I adjusted the settings as per this and this, so my web.config in the client and app.config in the WCF service look as follows:
web.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding maxReceivedMessageSize="10485760" name="WSHttpBinding_IMessengerService">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors >
<endpointBehaviors>
<behavior name="WSHttpBinding_IMessengerService">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost:8005/MessengerService/Service" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMessengerService" contract="MessengerService.IMessengerService">
<identity>
<servicePrincipalName value="Local Network" />
</identity>
</endpoint>
</client>
</system.serviceModel>
App.config:
<system.serviceModel>
<services>
<!-- This section is optional with the new configuration model introduced in .NET Framework 4. -->
<service name="Omnix.Messenger.Service.MessengerService" behaviorConfiguration="MessengerServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8005/MessengerService/Service" />
</baseAddresses>
</host>
<!-- this endpoint is exposed at the base address provided by host: http://localhost:8005/MessengerService/service -->
<endpoint address="" binding="wsHttpBinding" contract="Omnix.Messenger.Service.Contract.IMessengerService" />
<!-- the mex endpoint is exposed at http://localhost:8005/MessengerService/service/mex -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MessengerServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Can someone please point out what I'm doing wrong, and how to resolve the issue?
You also need to set the same configuration on server side.
In your app.config add the binding configuration:
<system.serviceModel>
<!-- add the lines below -->
<bindings>
<wsHttpBinding>
<binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" name="WSHttpBinding_IMessengerService">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
Also change Web.config:
<binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" name="WSHttpBinding_IMessengerService">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
Hope it helps
i want to enable (SessionMode=SessionMode.Required) in my service, so when i have enabled it then test the service using WCF Client Test it raise the following error:
The message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.HTTP GET Error
URI: http://localhost:7645/PublisherService.svc
The HTML document does not contain Web service discovery information.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="myBasicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00" receiveTimeout="00:01:00">
<readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
<!--enable WSHTTPBinding session-->
<wsHttpBinding>
<binding name="bindingAction" transactionFlow="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" sendTimeout="00:01:00" receiveTimeout="00:01:00" closeTimeout="00:01:00" openTimeout="00:01:00">
<readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
<reliableSession enabled="true"/>
<security mode="Transport">
<message establishSecurityContext="false" clientCredentialType="IssuedToken"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
<services>
<service name="AllChatService.PublisherService" behaviorConfiguration="metadataSupport">
<host>
<baseAddresses>
<add baseAddress ="http://localhost:7645/"/>
</baseAddresses>
</host>
<endpoint contract="AllChatService.PublisherService" binding="wsHttpBinding" address=""/>
<!--Enable Meta Data Publishing-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceDebug includeExceptionDetailInFaults="False" />
<!--Enable WSDL Data Binding-->
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
[ServiceBehaviorAttribute(InstanceContextMode = InstanceContextMode.PerCall)]
public class PublisherService : IPublisher
{
}
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IPublisher
{
}
So can any one help me to solve this problem.
remove the line
<security mode="Transport">
from your web.config file. because Transport seems to require HTTPS to encrypt credentials.