I've been working on converting a basicHttpBinding to a customBinding to get my client working on a web farm. I've been fumbling translating the following security section.
<basicHttpBinding ...>
<security mode="Transport">
<transport clientCredentialType="Certificate">
</security>
</basicHttpBinding>
<behaviors>
<behavior>
<clientCredentials>
<clientCertificate
x509FindType="FindBySerialNumber"
findValue="..."
/>
</clientCredentials>
<behavior>
</behaviors>
I'd show you my translation, but what I've been able to fathom is really undereducated guessing. I will also continue doing some more independent research via the web.
This tool converts automatically your binding into a customBinding.
http://webservices20.cloudapp.net/default.aspx
Ok, I figured this out, didn't need to even use the security section in the custombinding, everything I need to set was on the <httpsTransport/> element itself. I've cut out all the non important bits.
<customBinding>
<binding name="viaLoadBalancers">
<textMessageEncoding
messageVersion="Soap11"
writeEncoding="utf-8"
/>
<httpsTransport
authenticationScheme="Anonymous"
requireClientCertificate="true"
/>
</binding>
</customBinding>
Related
I made my first WCF service where I'm receiving data I have to process. The problem occurs when I send larger amounts, a 100mb soap message, of data at once, I get the reply Error 400 Bad Request.
I tried setting maxReceivedMessageSize, maxBufferSize, maxAllowedContentLength, readerQuotas that are referenced in other questions, but nothing seems to work or just makes the service not work at all.
These are the current settings in my web.config
<services>
<service name="RMQServices.RMQ_WS1" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="webHttp" contract="RMQServices.RMQService" binding="basicHttpBinding" bindingConfiguration="myBasic" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBasic" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:30:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxArrayLength="2147483647"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
Am I still missing something in the config for it to work and accept larger requests?
EDIT:
If I send data via a service reference then it accepts even 1GB soap messages. But if I try to send it via HttpWebRequest with a prebuilt SOAP XML, then it still returns a Bad Request. So the problem seems to be in how I send the data.
make sure your client config also have these values
<client>
<endpoint address="[address]" binding="basicHttpBinding" bindingConfiguration="myBasic" contract="" name="Name" />
</client>
And then add
<bindings>
<basicHttpBinding>
<binding name="myBasic" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:30:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxArrayLength="2147483647"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
if this does not work, remove the security from the binding and then validate
Please try to add the following code snippets.
<behaviors>
<serviceBehaviors>
<behavior name="mybehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<httpRuntime maxRequestLength="2147483647" executionTimeout="3600" />
</system.web>
</configuration>
Also, Don’t forget to apply the configuration between the client-side and server-side (you should also add this configuration on both the client-side and server-side endpoints).
Feel free to let me know if the problem still exists.
I have a WCF service that is working great in production except for one new instance of a client that is unable to communicate with the service.
The WCF service runs over https on .Net 4.0 on a Windows Server 2008 R2 system. All clients are .Net 4.0 or higher (these are not under my control/config).
Enabling WCF Tracing in the service when this one client fails to connect shows this error:
"Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found."
I have verified the exact same URL and WSDL are used by working clients and the one nonworking client. I CAN view the service information site and WSDL over https using a web browser.
I am suspecting a possible SSL/TLS negotiation failure, but wanted to check to see if others are familiar with this particular type of situation.
Here is my service web config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_INamedService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="NamedService.NamedServiceService">
<endpoint address="/NamedServiceService" binding="basicHttpBinding" bindingNamespace="https://my.domain.com/NamedServiceService" bindingConfiguration="BasicHttpBinding_INamedServiceService" contract="NamedServiceService.INamedServiceService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
Possibly a typo in your endpoint bindingConfiguration:
bindingConfiguration="BasicHttpBinding_INamedServiceService"
Your binding is named: BasicHttpBinding_INamedService not BasicHttpBinding_INamedServiceService
<basicHttpBinding>
<binding name="BasicHttpBinding_INamedService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
not sure what your contract name is but it does have ServiceService in it too, might want to double check that out.
If it is in the same project, why is your service implement and service interface namespace different? There may be some spelling mistakes in your configuration. I suggest you check it carefully.
name="NamedService.NamedServiceService"
contract="NamedServiceService.INamedServiceService"
Besides, try to use the following configuration to set up https protocol.
<bindings>
<webHttpBinding>
<binding name="myhttpsbinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
<binding name="myhttpbinding">
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
Feel free to let me know if there is anything I can help with.
I am trying to pass large byte array to wcf service from windows phone application. I have tried all possible way's to pass large byte array but I couldn't pass it.
Here is my web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!--<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:00" closeTimeout="00:10:00">
<security mode="None" />
</binding>-->
<binding closeTimeout="01:30:00"
openTimeout="01:30:00" receiveTimeout="01:30:00" sendTimeout="01:30:00" transferMode="Streamed"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="4294967295">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
I have used the max received message size i.e. 2147483646. Now I will show my
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx.xx.x.xxx/WebService/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="MyService.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I am passing following parameter to my wcf service method
Service1.svc.cs
public string GetDataUsingDataContract(byte[] fileByte,string fileName,string folderName)
{
}
I have searched a lot and I found one similar example Maximum array length quota
But I heard that windows phone 8 doesn't support netTcpBinding. I have read that we can pass 2GB file to wcf service. How can I pass max byte array? I am stuck with this problem. Can someone please help me to solve this?
This is quite a common exception - have a look at the following posts on msdn social:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/4fe7c526-510d-46ab-acac-9719e696f7db/an-exception-of-type-systemservicemodelcommunicationexception-occurred-in
http://social.msdn.microsoft.com/Forums/wpapps/en-US/61f1060f-846e-4e7d-b8ff-c2956e0a8677/visual-studio-2012-windows-phone-8-wcf-systemservicemodelcommunicationexception
Both seem to point to a problem with the windows 8 phone emulator. Instructions on how to work around this here:
http://countofmontecito.com/2012/11/13/wcf-and-windows-phone-8/
Full documentation here:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx
I'm recently installed the 4.5 framework on our development web server which runs IIS 7.5 on Windows Server 2008. After installation, two web services started having the same error. These web services were built using the MS REST Starter Kit. Here is the error I'm getting.
A binding instance has already been associated to listen URI . If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.
Here is a copy of the system.service model section of our config file.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding>
<security mode="Transport" />
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="EnterpriseIdentityBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://betaapps/EnterpriseIdentity/V1/UserService.svc"
binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
contract="UserServiceWCF.IUserService" name="wsSecureUsers" />
<endpoint address="https://betaapps/EnterpriseIdentity/V1/RoleService.svc"
binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
contract="RoleServiceWCF.IRoleService" name="wsSecureRoles" />
</client>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="Hsmv.Web.Security.IdentityModel.HttpContextWithRolesPolicy, Hsmv.Web.Security" />
</authorizationPolicies>
</serviceAuthorization>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Any idea why this error would occur after installing .Net 4.5?
I would like to add that I tried removing this section and it does work without it.
<webHttpBinding>
<binding>
<security mode="Transport" />
</binding>
</webHttpBinding>
I use this because this service runs on ssl. I heard that WCF 4.5 tries to create bindings and endpoints for you so they don't need to be in the web.config. So I wondered if this section is being automatically built by WCF and is not needed. Or is my thinking incorrect?
Thanks!
I am from WCF team. Thanks for reporting this issue. WCF team will continue to investigate this issue for fix. While we investigate you can work around this by explicitly configuring a webHttp endpoint in your configuration file. Service will be the same by behavior like before. Try to follow these simple steps.
(I am taking the configuration file that you have published in this post as a starting point)
Comment out the <standardEndpoints> tag in your configuration file:
<!--<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>-->
Add this end point behavior to your list like this:
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
Explicitly configure your service endpoint in the config file like this. For highlighted attribute values substitute your service type name and contract name respectively (Note: if you don’t have a contract defined for service, then insert service type name in contract=”” too)
<services>
<service name="WcfRestService1.Service1">
<endpoint address="" binding="webHttpBinding" contract="WcfRestService1.Service1" behaviorConfiguration="REST" />
</service>
</services>
In my case, the problem solved once I removed the <security/> tag from the web.config. I had it setted to "none", so this may not apply to your particular case.
My WCF never worked with wsbinding, but when I switched to basic it worked fine.
What do I have to do to make wsbinding work?
Update
when I say it didn't work, I mean the client was never able to consume the services endpoints.
Do I have to add a username/password somewhere?
First, are you using Visual Studio 2005 or 2008? Next if you are using VS2005 did you install the .NET 3.0 CTP tools for WCF/WF that was released in 2006? I ask these questions because I wanted to know how you setup your proxy class in the client. Did you right click and do "add service reference" or "add web reference"
Also, does your WCF config file look similar to the below? This shows a dual setup, both Basic and WsHttp Bindings.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttp">
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
<basicHttpBinding>
<binding name="basicHttp"/>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NorthwindBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NorthwindBehavior" name="SampleApplicationWCF.Library.SupplierService">
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttp" name="wsHttpSupplierService" contract="SampleApplicationWCF.Library.ISupplierService" />
</service>
</services>
</system.serviceModel>