I'm using the following code successfully with HTTP but I would like to use SSL. When I change the endpoint address to https and modify the security mode to Transport in the web.config I get the error : "The provided URI scheme 'https' is invalid; expected 'http'."
This is a VB.net test form.
Imports WindowsApplication1.WCFService
Imports System.ServiceModel
Public Class Form1
Private WCFConnection As Service1Client 'Class reference from the ServiceReference
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
If WCFConnection Is Nothing Then
WCFConnection = New Service1Client(New System.ServiceModel.BasicHttpBinding(), New EndpointAddress("https://www.mysite.com/Service1.svc?wsdl"))
End If
Dim NParray As String = WCFConnection.GetNP("8")
TextBox1.Text = NParray
End Sub
End Class
Then here is the web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://www.mysite.com/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="WCFService.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
I've figured this out.
Here is the web.config that I'm using
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServBehave">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServBehave" name="FILE_WCF.Srv">
<endpoint address="" binding="customBinding" bindingConfiguration="custBind"
contract="FILE_WCF.ISrv" />
</service>
</services>
<bindings>
<customBinding>
<binding name="custBind">
<binaryMessageEncoding></binaryMessageEncoding>
<httpsTransport></httpsTransport>
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here is the SVC file
<%# ServiceHost Language="VB" Debug="true" Service="FILE_WCF.Srv" CodeBehind="FILE.svc.vb" %>
Instead of
security mode="None"
use
security mode="None"
Related
I have one WCF rest service operation contract which internally calls another service.
While making a call to another service, It adds certificate and makes a call to the other service.
My operation contract is like below
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/report/videodata/{component}/{count}")]
ServiceResponse CallcomponentHandler(string component, string count);
and my implementation is like below
public ServiceResponse CallcomponentHandler(string component, string count)
{
//Making HTTP Get Request to another service
return utility.GetResponse(Url);
}
But when I am trying to consume this Operation from internet explorer, This is getting called multiple times.
Please note the other service has async method.
I tried adding maxReceivedMessageSize,maxStringContentLength in web.config file but still not able to resolve this.
Below is my web.config file.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<services>
<service name="Video.GetDetails" behaviorConfiguration="MyServiceBehavior">
<endpoint name="rest" address="" binding="webHttpBinding" contract="Video.IService1" behaviorConfiguration="restBehavior"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="StreamedRequestWebBinding"
bypassProxyOnLocal="true"
useDefaultWebProxy="false"
hostNameComparisonMode="WeakWildcard"
sendTimeout="10:15:00"
openTimeout="10:15:00"
receiveTimeout="10:15:00"
maxReceivedMessageSize="9223372036854775807"
maxBufferPoolSize="9223372036854775807"
maxBufferSize="2147483647"
transferMode="StreamedRequest" >
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="Binding1" closeTimeout="04:01:00" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824" maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824"/>
</binding>
<!-- For Cyber Source bindings-->
<binding name="ITransactionProcessor" closeTimeout="04:01:00" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824" maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824"/>
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<!--Cyber Source bindings ends here-->
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" 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>
Please help me on this.
I'm coding a webservice at the moment and the usage is as followed:
I got a frontend as dll, means I got a library project with a wpf window.
That library shall be called from other programs.
The Backend WCF-service is hosted on an external IIS and the frontend calls the webservice methods via a controller.dll where the wcf service is referenced.
I've read several post here and from google already about the same issue...but I can't get it fixed.
I got a dummy windows forms, which calls the frontend.dll.
That project got that app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://Hidden-ip/TicketReportService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>
I'm aware, that each program that wants to call my frontend.dll would need to put the binding/endpoint configurations in their own app.config if I proceed like i described here.
Thats just an example though, later I'm doing the binding/endpoint config programaticallly in my controller.dll, so I dont need configuration files...but thats another topic.
If I call my method, that uploads the file via the webservice I got two scenarios:
if file > 16kb and <~30kb I get a protoccol exception, thats telling me that the "MaxArrayLength" (16384) was exceeded.
if I'm trying to upload a file with about 60kb I get a protocoll exception as well, but just with the information: "remoteserver returned unexpected answer.(400) bad request.
If you look in the app.config, the maxarray length is setted to int32.max value.
Also if I check the binding of the object that calls the method, its telling me that the maxarraylength was taken from the app.config....but I'm still getting the error message.
What did I wrong here?
Thats a client side issue, i'snt it?
In my service web.config on the IIS I got following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="BackendService.Behavior" name="MyNamespaye.Service">
<endpoint address="" binding="basicHttpBinding" contract="MyNamespaye.IService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BackendService.Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<connectionStrings>
<add name="CustomerEntities" connectionString="metadata=res://*/CustomerModel.csdl|res://*/CustomerModel.ssdl|res://*/CustomerModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=hidden-ip;User Id=root;database=fromcloud;password=hidden-pw;Persist Security Info=True"" providerName="System.Data.EntityClient" />
<add name="DocumentEntities" connectionString="metadata=res://*/DocumentModel.csdl|res://*/DocumentModel.ssdl|res://*/DocumentModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=hidden-ip;User Id=root;password=hidden-pw;Persist Security Info=True;database=fromcloud"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
...fixed it myself. Didn't know that it has to be configured on the service side as well!
new web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="BackendService.Behavior" name="MyNamespace.Service">
<host>
<baseAddresses>
<add baseAddress="http://localhost:1111/"/>
</baseAddresses>
</host>
<endpoint address="http://MyIP/TicketReportService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService"
contract="Mynamespace.BackendService.IService"
name="ticketReport_endpoint" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BackendService.Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<connectionStrings>
<add name="CustomerEntities" connectionString="metadata=res://*/CustomerModel.csdl|res://*/CustomerModel.ssdl|res://*/CustomerModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=fwefwef;User Id=root;database=fromcloud;password=fwefw;Persist Security Info=True"" providerName="System.Data.EntityClient" />
<add name="DocumentEntities" connectionString="metadata=res://*/DocumentModel.csdl|res://*/DocumentModel.ssdl|res://*/DocumentModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=fwefwef;User Id=root;password=fwef;Persist Security Info=True;database=fromcloud"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
...just did another google search and found a proper exampel of a web.config.
Thanks anyway for anyone that read the OP.
I read this article http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP to upload large file via WCF.
I've created the same configuration but I've just upload file 48kb even I added attribute maxReceivedMessageSize ="2147483647". When I try to upload file over 48kb I got an error
The remote server returned an error: (413) Request Entity Too
Large.
Did I get wrong or miss something? Below is my config
Server config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="4800" maxRequestLength="2097150"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<!--BINDING-->
<bindings>
<basicHttpBinding>
<binding name="TransferService"
closeTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize ="2147483647"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
messageEncoding="Text"
transferMode="Streamed"
>
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxArrayLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<!--SERVICE-->
<services>
<service name="TransferService.TransferService"
behaviorConfiguration="TransferServiceBehavior" >
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="TransferService"
contract="TransferService.ITransferService" >
</endpoint>
</service>
</services>
<!--BEHAVIOR-->
<behaviors>
<serviceBehaviors>
<behavior name="TransferServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000"></requestLimits>
</requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Web client config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_ITransferService"
address="http://localhost/transfer/TransferService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITransferService"
contract="TransferService.ITransferService" />
</client>
</system.serviceModel>
Please suggest any solutions.
Thanks in advance
Now I've changed config as your suggest but it's still raise the same error 400 or 413. Below is my test project. I don't know reason why? (Environment: Window 7 Pro 64 bit, IIS7 , WCF 4.0)
https://skydrive.live.com/redir?resid=BFE92959302FBAA0!105&authkey=!ANO_URChpql9gKE
I'm spent two week to research and but it's the same error.
Please help me. Thanks in advance.
Well, the client config must also define the same binding configuration (with the larger transfer size), and specify that binding configuration in its endpoint configuration!
So change your client side config to:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="TransferService"
closeTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize ="2147483647"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
messageEncoding="Text"
transferMode="Streamed"
>
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxArrayLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_ITransferService"
address="http://localhost/transfer/TransferService.svc"
binding="basicHttpBinding"
bindingConfiguration="TransferService"
contract="TransferService.ITransferService" />
</client>
</system.serviceModel>
and then you should have the same settings on the client and the server, and then those settings would become useful !
I checked your project, replace your webconfig with this and update the service reference try again,
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="4800" maxRequestLength="2097150"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<!--BINDDING-->
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<customBinding>
<binding name="LargeSilverlight" closeTimeout="00:21:00" openTimeout="00:20:00"
receiveTimeout="00:20:00" sendTimeout="00:50:00">
<textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
</client>
<!--SERVICE-->
<services>
<service name="TransferService.TransferService" behaviorConfiguration="SilverlightWCFLargeDataApplication" >
<endpoint address="" binding="customBinding" bindingConfiguration="LargeSilverlight" behaviorConfiguration="SilverlightWCFLargeDataApplication" contract="TransferService.ITransferService" >
</endpoint>
</service>
</services>
<!--BEHAVIOR-->
<behaviors>
<serviceBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="500000000"></requestLimits>
</requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I am facing Same Problem. and I am used this code in config File then I am able to upload 25MB file
try this
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="webserviceMOSSuiteSoap"
closeTimeout="00:01:00"
maxBufferPoolSize="20000000"
maxBufferSize="20000000"
maxReceivedMessageSize="20000000"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
messageEncoding="Text"
transferMode="Buffered"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="20000000"
maxArrayLength="20000000"
maxBytesPerRead="20000000"
maxNameTableCharCount="20000000"/>
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm=""/>
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WebServiceConnect/webservice.asmx"
binding="basicHttpBinding"
bindingConfiguration="webserviceMOSSuiteSoap"
contract="ServiceReference1.webserviceMOSSuiteSoap"
name="webserviceMOSSuiteSoap"/>
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
I have a WCF Service being hosted on IIS 5.1 with Anonymous access disabled. Below is a part of the web.config file showing how the service is configured:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingCfg">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="HelloService">
<endpoint name="BasicHttpEndpoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingCfg"
contract="IHelloService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Every time I call any operations that this service exposes from a desktop application, I receive the following error message:
Either a required impersonation level was not provided, or the
provided impersonation level is invalid.
Please note that binding type and hosting environment is pre-determined by the client and cannot be changed.
Any help that may lead to resolving this issue would be greatly appreciated.
Thanks!
Zen
EDIT: Here is how the client is configured:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpEndpoint"
address="http://vm00000033871b.intra.pri/WCFServiceBasicHttp/HelloService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="Proxy.IHelloService" />
</client>
</system.serviceModel>
Try this to pass the current users Windows credentials:
Using proxy As New PRX.HelloServiceClient()
proxy.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation
proxy.ChannelFactory.Credentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials
Dim message As String = proxy.Hello("Hi")
MessageBox.Show(message)
End Using
I am getting the following error using WCF, calling the a WCF Service on another server.
An error (The request was canceled)
occurred while transmitting data over
the HTTP channel.
The following Services worked on a IIS7 Box on .net3, but we have recently upgraded to IIS7.5 and .net 3.5sp1, if I remove the AllowNtlm attribute out of the Config, the call gets further but does not pass allow the service to do a double hop to the database, i then get the follow error.
'NT AUTHORITY\ANONYMOUS LOGON'.
I have enclosed a copy of the client app.config, which worked using iis7, but
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Windows">
<clientCredentials>
<windows allowNtlm="false" allowedImpersonationLevel="Delegation"/>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="4194304"></dataContractSerializer>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="4194304" maxReceivedMessageSize="4194304" messageEncoding="Text" name="BasicHttpBinding_CalculationWebService" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:10:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"></readerQuotas>
<security mode="TransportCredentialOnly">
<message algorithmSuite="Default" clientCredentialType="UserName"></message>
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server1.domain/WebServices/CacheManagement/CacheBusinessService.svc" behaviorConfiguration="Windows" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CacheWebService" contract="CacheWCFService.CacheWebService" name="BasicHttpBinding_CacheWebService">
<identity>
<servicePrincipalName value="http/server1.domain"></servicePrincipalName>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
This is the Server Config, any ideas?
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="CacheManagementBehavior" name="Iris.WebServices.CacheManagement.CacheWebService">
<endpoint address="" behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_CacheManagement" contract="Iris.WebServices.CacheManagement.CacheWebService" />
<endpoint address="mex" behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_CacheManagement" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_CacheManagement" maxReceivedMessageSize="4194304" receiveTimeout="00:30:00">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CacheManagementBehavior">
<dataContractSerializer maxItemsInObjectGraph="4194304" ignoreExtensionDataObject="True"/>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
</behavior>a
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
We managed to resolve the issue, by removing ServicePrincipleName from the config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Windows">
<clientCredentials>
<windows allowNtlm="false" allowedImpersonationLevel="Delegation"/>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="4194304"></dataContractSerializer>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="4194304" maxReceivedMessageSize="4194304" messageEncoding="Text" name="BasicHttpBinding_CalculationWebService" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:10:00" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"></readerQuotas>
<security mode="TransportCredentialOnly">
<message algorithmSuite="Default" clientCredentialType="UserName"></message>
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server1.domain/WebServices/CacheManagement/CacheBusinessService.svc" behaviorConfiguration="Windows" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CacheWebService" contract="CacheWCFService.CacheWebService" name="BasicHttpBinding_CacheWebService" />
</client>
</system.serviceModel>
</configuration>