I am consistently getting this error:
Could not establish trust relationship for the SSL/TLS secure channel
with authority 'dev1sintiaweb01'.
I am sure, I had signed the certificate. Why do I still get this error? What can I do to fix it?
This is my Server WebConfig.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SpasiWebService.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings />
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.6.1">
</compilation>
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="SpasiService.IService1">
<endpoint address="basic" binding="basicHttpsBinding" contract="SpasiService.IService1" />
</service>
</services>
<bindings>
<basicHttpsBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpsBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
This is My Client AppConfig.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DosirAsli.My.MySettings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
<!-- 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>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<userSettings>
<DosirAsli.My.MySettings>
<setting name="strLinkMyBCA" serializeAs="String">
<value>https://mybcaportal/sites/ai/Aplikasi Pengawasan Internal/</value>
</setting>
</DosirAsli.My.MySettings>
</userSettings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
</providers>
</entityFramework>
<system.net>
<settings>
<servicePointManager checkCertificateName="false" checkCertificateRevocationList="false" />
</settings>
</system.net>
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="BasicHttpsBinding_IService1" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpsBinding>
</bindings>
<!--<client>
</client>-->
<client>
<endpoint address="https://dev1sintiaweb01/WebServiceSpasi/Service1.svc"
binding="basicHttpsBinding" bindingConfiguration="BasicHttpsBinding_IService1"
contract="SpasiWebService.IService1" name="BasicHttpsBinding_IService" />
</client>
</system.serviceModel>
</configuration>
Error Stack Trace
Server stack trace: at
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException
webException, HttpWebRequest request, HttpAbortReason abortReason)
at
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout) at
System.ServiceModel.Channels.RequestChannel.Request(Message message,
TimeSpan timeout) at
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message
message, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
DosirAsli.SpasiWebService.IService1.CekDomainTersedia(String
strDomain) at
DosirAsli.SpasiWebService.Service1Client.CekDomainTersedia(String
strDomain) in E:\Project CAAT\Web
PI\Web_PI\WebPI-DevBranch\DosirAsli\Connected
Services\SpasiWebService\Reference.vb:line 96 at
DosirAsli.Login.btnLogin_Click(Object sender, EventArgs e) in
E:\Project CAAT\Web PI\Web_PI\WebPI-DevBranch\DosirAsli\Login.vb:line
43
Related
I created A WCF Application that has 3 methods to return some users Data for test. that It has no Problem I tested.
I added the Web Reference in Xamarin But When I want to use the method it has Error Exception.
WCF web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.8" />
<httpRuntime targetFramework="4.8" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpointBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyStoreService.MyStoreService"
behaviorConfiguration="MyBehavior">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="MyBinding"
behaviorConfiguration="EndpointBehavior"
contract="MyStoreService.IMyStoreService"
name="MyStoreService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:58514/MyStoreService.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MyBinding" >
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="ServiceConnection" connectionString="Data Source=.;Initial Catalog=StoreDb;Integrated Security=true;" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
this is the Code I Use in Xamarin android with C#
localhost.MyStoreService service = new MyStoreService();
var user = service.UserGetById(1, true);
label.Text = user.FName;
And this is the Error Exception
{System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused at System.Net.Sockets.SocketAsyncResult.CheckIfThrowDelayedException () [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:127 at System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult) [0x0002c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net.Sockets/Socket.cs:1214 at System.Net.WebConnection+<>c.<Connect>b__16_1 (System.IAsyncResult asyncResult) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebConnection.cs:182 at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x00019] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs:538 --- End of stack trace from previous location where exception was thrown --- at System.Net.WebConnection.Connect (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) [0x00197] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebConnection.cs:180 --- End of inner exception stack trace --- at System.Net.WebConnection.Connect (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) [0x0025d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebConnection.cs:202 at System.Net.WebConnection.InitConnection (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) [0x000cc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebConnection.cs:273 at System.Net.WebOperation.Run () [0x00052] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebOperation.cs:268 at System.Net.WebCompletionSource`1[T].WaitForCompletion () [0x0008e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/System.Net/WebCompletionSource.cs:111 at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x000a7] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs:364 at MyStoreApplication.localhost.MyStoreService.UserGetById (System.Int64 UId, System.Boolean UIdSpecified) [0x00001] in F:\StoreProject\MyStoreApplication\MyStoreApplication\Web References\localhost\Reference.cs:227 at (wrapper remoting-invoke-with-check) MyStoreApplication.localhost.MyStoreService.UserGetById(long,bool) at MyStoreApplication.MainActivity.GetData () [0x00007] in F:\StoreProject\MyStoreApplication\MyStoreApplication\MainActivity.cs:147 at MyStoreApplication.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x000aa] in F:\StoreProject\MyStoreApplication\MyStoreApplication\MainActivity.cs:47 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00010] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.App.Activity.cs:2986 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr)}
I am new to wcf and xamarin. Please help me to solve the problem?
this is the Pic may help
[1]: https://s21.picofile.com/file/8444961626/Error.png
I am working on WCF in following scenario
"Authenticating and Authorizing Users by Using the SQL Membership Provider and the SQL Role Provider"
Host : Asp.NET website
Client : Console application.
I am using WsHttpBinding over HTTPS communications (at my local),
I am getting following exception while communicating
Unhandled Exception:
========================================================
System.ServiceModel.Security.MessageSecurityException: An u
nsecured or incorrectly secured fault was received from the other party. See the
inner FaultException for the fault code and detail. ---> System.ServiceModel.Fa
ultException: At least one security token in the message could not be validated.
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChann
el.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState
, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChann
el.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperat
ion(SecuritySessionOperation operation, EndpointAddress target, Uri via, Securit
yToken currentToken, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetToken
Core(TimeSpan timeout)
at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan tim
eout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecurit
ySessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceMod
el.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeo
ut)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeS
pan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at ProductsClient.ProductsService.IProductsService.ListProducts()
at ProductsClient.ProductsService.ProductsServiceClient.ListProducts() in D:\
Visual Studio\WCF\PracticeInNotes\51Web_HttpHost_SQLAuth_SQLAutr_TrSec\Web_HttpH
st_SQLAuth_SQLAutr_TrSec\ProductsClient\ProductsService.cs:line 285
at ProductsClient.Program.Main(String[] args) in D:\Visual Studio\WCF\Practic
eInNotes\51Web_HttpHost_SQLAuth_SQLAutr_TrSec\Web_HttpHst_SQLAuth_SQLAutr_TrSec\
ProductsClient\Program.cs:line 45
Press any key to continue . . .
Here is Web.Config of Host Web Site
===================================
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<dataConfiguration defaultDatabase="AdventureWorksConnection" />
<connectionStrings>
<add name="AdventureWorksConnection" connectionString="Data Source=WIN764\SQL2008;Initial Catalog=AdventureWorks2008;User ID=sa;Password=123" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ProductsServiceWSHttpBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ProductsBehavior" name="ProductsService.ProductsServiceImpl">
<endpoint address="https://localhost/InternetProductsService/ProductsService.svc" binding="wsHttpBinding"
bindingConfiguration="ProductsServiceWSHttpBindingConfig" name="ProductsServiceWSHttpEndpoint"
contract="ProductsService.IProductsService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProductsBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles"
roleProviderName="AdventureWorksSqlRoleProvider" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="AdventureWorksSqlProvider" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" >
<filters>
<clear/>
</filters>
</messageLogging>
</diagnostics>
</system.serviceModel>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<authentication mode="Forms" />
<membership defaultProvider="AdventureWorksSqlProvider">
<providers>
<clear />
<add name="AdventureWorksSqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="AdventureWorksConnection" applicationName="InternetProductsService " />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="AdventureWorksSqlRoleProvider">
<providers>
<clear />
<add name="AdventureWorksSqlRoleProvider" connectionStringName="AdventureWorksConnection" applicationName="InternetProductsService " type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>
</system.web>
</configuration>
Here is App.Config of Client Application
========================================
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ProductsClientWSHttpBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/InternetProductsService/ProductsService.svc"
binding="wsHttpBinding"
bindingConfiguration="ProductsClientWSHttpBindingConfig"
contract="ProductsClient.ProductsService.IProductsService"
name="WSHttpBinding_IProductsService" />
</client>
</system.serviceModel>
Have spent over 20 hrs searching the web and still cant get basichttpbinding to save when
has a number of records (okay when a small number of records)
The service Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
<pages>
<namespaces>
<add namespace="System.Runtime.Serialization" />
<add namespace="System.ServiceModel" />
<add namespace="System.ServiceModel.Web" />
</namespaces>
</pages>
<httpRuntime executionTimeout="600" maxRequestLength="102400"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="IncidentServiceBehavior" name="NewIncidentService_IService">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="IncidentServiceReference.ServiceClient" />
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Incident"
name="" contract="IncidentServiceReference.ServiceClient" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<timeouts closeTimeout="01:10:00" />
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="01:10:00"
openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="524288" maxReceivedMessageSize="524288" transferMode="Streamed">
<readerQuotas maxDepth="524288" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_Incident" maxReceivedMessageSize="524288"
useDefaultWebProxy="false">
<readerQuotas maxDepth="524288" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="IncidentServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="524288" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
The client App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.web>
<httpRuntime executionTimeout="600"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService"
maxReceivedMessageSize="524288"
maxBufferSize="524288"
maxBufferPoolSize="524288"
receiveTimeout="01:10:00"
transferMode="Streamed"
sendTimeout="01:10:00"
closeTimeout="01:10:00"
hostNameComparisonMode="StrongWildcard"
openTimeout="01:10:00"
messageEncoding="Text"
textEncoding="utf-8"
allowCookies="false"
bypassProxyOnLocal="false"
useDefaultWebProxy="false">
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="IncidentServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="524288"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="---Removed for security-----"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="IncidentServiceReference.IService" name="BasicHttpBinding_IService" behaviorConfiguration="IncidentServiceBehavior" />
</client>
</system.serviceModel>
</configuration>
Has a 413 error - changed to streamed, now get a 400. Error from WCF Test Client
The remote server returned an unexpected response: (400) Bad Request.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IService.saveTasks(saveTasksRequest request)
at ServiceClient.IService.saveTasks(saveTasksRequest request)
Inner Exception:
The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Yes it appears to be a time out, any changes not affect. Have added a timeout in the connectionstring and in IIS 7.0 have added 'serverruntime uploadreadaheadsize="20480000" '
any thoughts would be appreciated
Andrew
May have a solution for this.
Found this
binding name="" openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
at this site
http://www.codeproject.com/Questions/481526/Theplusremoteplusserverplusreturnedplusanplusunexp
Needs to before any other basichttpbinding and note that there is no name. I think this set the default values. have set up a test to see if it work and has not failed yet. I will (when time permits) change the values from 2gigs to lower values.
Hope this helps anyone with a similar issue.
Andrew
I've been doing a fair bit of research over the last two days to find a solution to my problem but to no avail.
I have created a WCF service like so:
[OperationContract]
void CopyMemberFile(string memberNumber, string fileName, byte[] fileBytes);
And I call it from my client like so from a page_load event:
byte[] filebytes = null;
using (Stream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
filebytes = new byte[fs.Length];
fs.Read(filebytes, (int)0, (int)fs.Length);
}
client.CopyMemberFile(memberNumber, Path.GetFileName(file), filebytes);
My configuration is like so:
Client Config:
<configuration>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="300" cookieless="UseUri" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<properties>
<add name="FirstName"/>
<add name="LastName"/>
<add name="MemberNumber"/>
<add name="LastVisit" type="System.DateTime"/>
</properties>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory" />
<add path="Telerik.Web.UI.WebResource.axd"
type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
<httpRuntime maxRequestLength="1048576"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="online.members.asp.Services.MembersOnlineSeviceAjaxAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="online.members.asp.Services.MembersOnlineSeviceAjax">
<endpoint address="" behaviorConfiguration="online.members.asp.Services.MembersOnlineSeviceAjaxAspNetAjaxBehavior"
binding="webHttpBinding"
contract="online.members.asp.Services.MembersOnlineSeviceAjax" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMembershipApplications"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128"
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://localhost:58119/MembershipApplications.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMembershipApplications"
contract="MembershipApplicationsServiceReference.IMembershipApplications"
name="BasicHttpBinding_IMembershipApplications" />
</client>
</system.serviceModel>
Service Config:
<configuration>
<system.web>
<roleManager enabled="true" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
The error I'm getting is this:
3/02/2013 11:12:39 AM: Upload.aspx Error: The remote server returned an unexpect
ed response: (400) Bad Request.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResp
onse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factor
y, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
pan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
e, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at online.members.asp.MembershipApplicationsServiceReference.IMembershipAppli
cations.CopyMemberFile(String memberNumber, String fileName, Byte[] fileBytes)`
I can upload files at only a few KB each but any larger than say 8KB and thing just fails
Any help would be fantastic.
Calling code:
protected void Page_Load(object sender, EventArgs e)
{
var file = Request.Form["name"];
var memberNumber = Request.Form["memberNumber"];
var tempId = Guid.NewGuid();
var client = new MembershipApplicationsServiceReference.MembershipApplicationsClient();
client.LogEvent("Entered Upload.aspx");
try
{
byte[] filebytes = null;
using (Stream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
filebytes = new byte[fs.Length];
fs.Read(filebytes, (int)0, (int)fs.Length);
client.LogEvent("Starting service call from Upload.aspx");
client.CopyMemberFile(memberNumber, Path.GetFileName(file), filebytes);
}
client.LogEvent("Completed service call from Upload.aspx");
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
client.LogEvent("Upload.aspx Error: " + ex.Message + ex.StackTrace);
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
finally
{
client.LogEvent("Finishing up");
}
}
Looking at your service's config file, you're using .NET 4.0 and you're not specifying any binding, so you're going to receive the default settings for basicHttpBinding. As suggested in the comments above, update your config file for your service like this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMembershipApplications"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128"
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 name="YourServiceName">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMembershipApplications"
contract="YourFullyQualifiedContractName" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
This will tell WCF to use your settings for the basicHttpBinding rather than the .NET defaults.
Alternatively, you can omit the name attribute on the binding definition and WCF will use it as the default binding for all services handled by the config file (if you have more than one).
If that doesn't help, or if you're getting a different error now, let us know and we'll take it from there.
My code works perfect for files smaller than 45 Kb but when I upload files large files I get that error:
The remote server returned an error: (400) Bad Request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Source Error:
Line 120: [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
Line 121: WebApplication2.ServiceReference1.uploadfileResponse WebApplication2.ServiceReference1.IService1.uploadfile(WebApplication2.ServiceReference1.RemoteFileInfo request) {
Line 122: return base.Channel.uploadfile(request);
Line 123: }
Line 124:
Source File: C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Service References\ServiceReference1\Reference.cs
Line: 122
Stack Trace:
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +6115427
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +48
[ProtocolException: The remote server returned an unexpected response: (400) Bad Request.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9455983
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
WebApplication2.ServiceReference1.IService1.uploadfile(RemoteFileInfo request) +0
WebApplication2.ServiceReference1.Service1Client.WebApplication2.ServiceReference1.IService1.uploadfile(RemoteFileInfo request) in C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Service References\ServiceReference1\Reference.cs:122
WebApplication2._Default.Button2_Click(Object sender, EventArgs e) in C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Default.aspx.cs:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
This is my webconfig code for the server:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="2097151"
useFullyQualifiedRedirectUrl="true"
executionTimeout="14400"
/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SomeServiceServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<!-- 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 -->
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="Service1"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Service1.svc.cs" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="IService1" >
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
And this the web.config for the client
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="2097150" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SomeServiceServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SomeServiceServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" 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://localhost/WcfServicefiles/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
The below section of your servers web.config
<services>
<service name="Service1.svc.cs" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="IService1" >
</endpoint>
</service>
</services>
has some values for attributes that are wrong. The value for the name attribute of service element needs to be namespace.Service1 and similarly the contract attribute value of endpoint element needs to be namespace.IService1 as shown below:
<services>
<service name="<namespace>.Service1" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="<namespace>.IService1" >
</endpoint>
</service>
</services>
Just replace with the namespace of Service1 class. And that should work
Try follwing this example: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP