I have a Silverlight application that uploads files in chunks to a WCF service. When I run both the service and the Silverlight app locally everything works fine. When I deploy them both to IIS it will work for files that are smaller than the chunk size (16k in this case) but if the file is larger than that it fails. It is almost exactly like the problem described here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/19329afc-8a73-4756-80cd-bbdada75c0e2 but the solution there doesn't work for me, I already keep a strong reference to the WCF proxy instance. But in my case as in that one, a single asynch call will succeed but multiple calls will fail.
Here's the serviceModel entry from the web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="binaryHttpBinding" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00">
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" authenticationScheme="Anonymous" maxBufferSize="2147483647" transferMode="Buffered"/>
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="ADE.Web.IADEFileTransferService" >
<endpoint address="" binding="customBinding" bindingConfiguration="binaryHttpBinding"
contract="ADE.Web.ADEFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
You need to have the same readerQuotas settings on both client and server side i.e. your silverlight config file needs to have the same settings as well.
Also consider adding the dataContractSerializer element in the serviceBehaviour tab with maxItemsInObjectGraph as shown below
<serviceBehaviors>
<behavior name="default">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
Also you can try to add the maxRequestLength value of httpRunTime element as shown below:
<system.web>
<httpRuntime maxRequestLength ="32768"/>
</system.web>
Related
I haven't worked with WCF much. And as fast as it came, it passed me by and I was on to webmethods and api stuff. So I'm tasked with removing WCF Security from this old service. There are so many settings in the config, that I'm a little miffed. I really don't have time to revisit old tech at the moment and would like a quick solution to just disable the security requirement. Is it as simple as setting security mode = "None"?
service config
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehaviors" name="QSService.QSSService">
<endpoint address="" behaviorConfiguration="restfulQuality" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity"
contract="QSSContracts.IQSService"/>
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="basicHttpTransportSecurity"
contract="QSSContracts.IQSService"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/WCFRestAuthentication/api/"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<security mode="Transport"/>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHttpTransportSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="restfulQuality">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviors">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization principalPermissionMode="None"
serviceAuthorizationManagerType="xxx.xxx.Common.ADFSTokenHandling.xxxServiceAuthorizationManager, xxx.xxx.Common.ADFSTokenHandling"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
one of many client configs
<system.serviceModel>
<client>
<endpoint name="ICOSService" address="https://dev-svc-cossecurity.xxxservices.com/COSSecurityService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_ICOSService"
contract="COS.IService.ICOSService">
</endpoint>
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_ICOSService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthorization principalPermissionMode="None"
serviceAuthorizationManagerType="xxx.xxx.Common.ADFSTokenHandling.xxxServiceAuthorizationManager, xxx.xxx.Common.ADFSTokenHandling"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Security mode in WCF cannot be started or turned off with one click.
Here are a few things you can look for to try setting safe mode:
Change the security mode.
Set the ClientCredentialType Property.
Change TransportWithMessageCredential.
The first two items are in your code and you can change them. You can also follow this document for further information
As per microsoft suggest, for soap1.1, soap1.2, rest based i.e. json, xml, it can be configure from web config. So the web config will decide service based on address. But not working properly. Please suggest.
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="PaymentService.Service1">
<endpoint address="soapbasic" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" behaviorConfiguration="SampleServiceBehavior" contract="PaymentService.IService1" />
<endpoint address="json" binding="webHttpBinding" bindingConfiguration="webHttpBindingJson" behaviorConfiguration="jsonBehavior" contract="PaymentService.IService1"/>
<endpoint address="xml" binding="webHttpBinding" bindingConfiguration="webHttpBindingXml" behaviorConfiguration="poxBehavior" contract="PaymentService.IService1"/>
<endpoint address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PaymentService.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SampleServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceCredentials useIdentityConfiguration="false" />
</behavior>
<behavior name="SampleServiceBehaviorSOAP">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript/>
</behavior>
<behavior name="poxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding">
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttpBindingJson">
<security mode="None"/>
</binding>
<binding name="webHttpBindingXml">
<security mode="None"/>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
By adding behaviorConfiguration="SampleServiceBehavior" in service i.e. < service name="PaymentService.Service1" behaviorConfiguration="SampleServiceBehavior"> has solved problem. Thank u khlr for this answer.
As you've configured multiple endpoints I think you'll have to define a <baseAddress>-node.
Did you already try to get that service working with only one endpoint configured (ideally basicHttpBinding)? This way you can try step by step enhancing your service with other endpoints.
Another good idea would be to add a svclog into a <system.diagnostics>-node which could provide additional error details. Have a look at this: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx
Edit
Error was caused by a mistake in the configuration. Solution was putting the behaviorConfiguration-attribute into the right place.
After doing this i faced another issue with rest and soap both. It was multiple end point found in service. For solving this name should be added in end point ex < endpoint name="wsSoap" address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PaymentService.IService1"/>.
I added another answer for if user face this kind of issue if their multiple end point successfully worked.
If I send parameters which will cause a lot of data to be pulled I get the following error:
The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I have increased all of my timeouts. Is there something I have to do on the client side? I am wondering if this is because I am using wcftestclient? Do I need to adjust the operationTimeout?
My webconfig has the following:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Basic" sendTimeout="12:00:00" receiveTimeout="12:00:00" openTimeout="00:10:00" closeTimeout="00:10:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="8192"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CaseStudyBehavior" name="EDTFS.ADMS.CaseStudyService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="Basic"
name="Basic"
contract="EDTFS.ADMS.ICaseStudyService" />
<endpoint address="mex"
binding="mexHttpBinding"
name="Metadata"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CaseStudyBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceTimeouts transactionTimeout="24:00:00"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
In the WCF Test Client you will find a node called Config File beneath your service. Right-click this and select Edit with SvcConfigEditor to increase timeout on the client.
Can someone please tell me what I'm doing wrong below? I have been fighting with this for hours and believe that I have it right, but I have to be missing something. Basically for every service I have I would like to have to addresses. These services are to be hosted in IIS. I have been testing with IIS Express. My expectation is that I would access the services at /AuthService.svc/soap and /AuthService.svc/json, but that doesn't seem to be working. Below is the config I'm using.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="SecureBinding" allowCookies="true" maxReceivedMessageSize="67108864">
<readerQuotas maxArrayLength="67108864"/>
<security mode="Transport"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="SecureBinding" allowCookies="true" maxReceivedMessageSize="67108864">
<readerQuotas maxArrayLength="67108864"/>
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="AuthService" behaviorConfiguration="DefaultServiceBehavior">
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="SecureBinding"
contract="FormsAuthenticatingServices.Interfaces.IAuthService" />
<endpoint address="json"
binding="webHttpBinding"
bindingConfiguration="SecureBinding"
behaviorConfiguration="jsonBehavior"
contract="FormsAuthenticatingServices.Interfaces.IAuthService" />
</service>
<service name="DataService" behaviorConfiguration="DefaultServiceBehavior">
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="SecureBinding"
contract="FormsAuthenticatingServices.Interfaces.IDataService" />
<endpoint address="json"
binding="webHttpBinding"
bindingConfiguration="SecureBinding"
behaviorConfiguration="jsonBehavior"
contract="FormsAuthenticatingServices.Interfaces.IDataService" />
</service>
</services>
</system.serviceModel>
You should get the SOAP based metadata at /authservice.svc?wsdl and the REST based operations starting from the URI /authservice.svc/json
You will not see anything in a browser by hitting /authservice.svc/soap as SOAP assumes XML messages will be POSTed to the service whereas the browser is performing a GET. To use the SOAP service create a client project and generate a proxy using Add Service Reference pointing at the WSDL
In addition to Richard's answer, make sure the name attribute on the <service> element is the fully qualified name of the service class.
I've got a WCF Web MEthod that takes in an XElement object as a parameter. For one of my XML files (sized at 600KB or so) this works just fine, however, for this bigger XML file (about 5MB) I get a CommunicationException right away.
I've already increased the message sizes for my binding. Below is the ServiceModel section of my web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BIMIntegrationWS.metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="BIMIntegrationWS.IntegrationService.customBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="BIMIntegrationWS.metadataBehavior">
<endpoint address="" binding="customBinding" bindingConfiguration="BIMIntegrationWS.IntegrationService.customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
On the client, my ClientConfig looks like this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IBIMIntegrationService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:1895/IntegrationService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_IBIMIntegrationService"
contract="BIMIntegrationService.IBIMIntegrationService" name="customBindingEndpoint" />
</client>
</system.serviceModel>
Thanks in advance!
try to add following snippet into your web.config for the service application:
<system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>
When you host the service in web server you also have to tweak allowed request size for the web server.
Best regards,
Ladislav
Maybe your XElement has too many nodes/child elements, and you need to set the maxItemsInObjectGraph attribute under dataContractSerializer to something larger?
You probably need to change the values of the attributes of the <readerQuotas /> sub element of <binaryMessageEncoding />.
For more information, see:
http://msdn.microsoft.com/en-us/library/ms731325.aspx
http://forums.silverlight.net/forums/p/88704/205040.aspx
Update:
Can you try to increase the maxAllowedContentLength as described here:
http://social.msdn.microsoft.com/Forums/en/wcf/thread/e6e21132-ad3f-4135-8ab9-77923b099907
Do you know how to turn off VS host and to just deploy to IIS and give it a ping. Normal IIS 7 on your dev box will do just fine. You can still attach debugger etc, just won't have instantaneous F5 gratification but since your ocode is not dying on startup you don't need to see if from the fist line anyway :-)
If you would need to attach very early you could could make a mimimal method that doesn't tounch anything at all and just returns int constnat - just to bring up app pool so you can attach.