I have a WCF web service built in .NET 4.0 that is configured to require a username/password on each call and uses a Server certificate in the behaviour to encrypt the request. It currently uses wsHttpBinding. I have a .NET 4 utility app that lets me call the methods on this WCF web service just fine.
I need to call this service from a .NET 2.0 class library. The library is in VS 2010 but targetting .NET 2.0 - I would like to simply switch to .NET 4.0 but can't for political reasons and time constraints. So therefore wsHttpBinding and the server certificate as used now are out of the question from what I've read so far.
From reading bits and pieces I did the following:
Changed the binding to use
basicHttpBinding
Removed mention of the server certificate from the behaviours
Installed and
enabled WSE on the class library
project.
Try to use on the WCF web service methods in .NET 2.0 winforms app - epic fail!!
It doesn't matter how I seem to configure the binding at the server end HTTPS is just not acceptible; the only way to get it to let me call it at all is do use security mode of "None", grrrghhh! That of course allows me to call it but then the username/password details are not supplied and never get set on the WCF service and hence when it eventually tries to save it fails because the user ID is 0.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>
<services>
<service name="MyService.NameHere" behaviorConfiguration="NameOfMyConfigHere">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="DirectoryServices.IDirectorySubmitService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehaviourName">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="5242880">
<readerQuotas maxStringContentLength="5242880"/>
<security mode="None">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
If anyone could help me figure out the correct magic mumbo to put in I would be most appreciated.
All I want to do is call a WCF web method supplying a username/password and have it use SSL to encrypt. The service is running on IIS. The client is a winforms app.
The .NET 2.0 Framework does not include WCF (which was introduced in 3.0), so I don't see how you will achieve this easily. You might have to tell the politicians to bite the bullet and migrate to .NET 4.0.
Related
i had a WCF server running through a Console application, it will run as an azure service so i don't to host it in ISS.
I belived it work well and share datas to my web app through ajax request. But when i maked a service that recieve a filestream, i realized that my binding configuration is not used at all. My WCF work same without binding section.
My probleme concerne especially the key "maxReceivedMessageSize" because default value limit me to 8Ko request and it is a problem for uploading file.
Bindings section (that i can comment) :
<webHttpBinding>
<binding name="MyBindingConfig" crossDomainScriptAccessEnabled="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
Services section :
<service name="MyData.Service.MyDataServiceRestFull">
<endpoint binding="webHttpBinding"
contract="MyData.Service.IMyDataServiceRestFull" bindingName="MyBindingConfig" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:9997/MyDataServer"/>
</baseAddresses>
</host>
</service>
Note that i tryed with basicHttpBinding and i had same issue.
The problem is that you're incorrectly referring to your binding in your <endpoint/> element. You're using the bindingName attribute, when you should be using the bindingConfiguration attribute:
<endpoint binding="webHttpBinding"
contract="MyData.Service.IMyDataServiceRestFull"
bindingConfiguration="MyBindingConfig" />
I have made a REST service that receives a ZIP-file, process and check some stuff, and returns an ID. This works fine for smaller ZIP-files, but when sending larger files (currently testing with 17 Mb), and the processing takes longer, the service returns "502 Bad gateway - Web server received an invalid response while acting as a gateway or proxy server".
I have tried to change all the variables I could find in the web config:
<binding name="webHttpTransportSecurity" maxReceivedMessageSize="163840000" maxBufferSize="163840000" closeTimeout="04:00:00" openTimeout="04:00:00" receiveTimeout="04:00:00" sendTimeout="04:00:00">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
<httpRuntime maxRequestLength="2147483647" enable="true" requestLengthDiskThreshold="10240" useFullyQualifiedRedirectUrl="true" executionTimeout="1000" appRequestQueueLimit="4000000" />
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
Anyone have any idea how to make this work with bigger files? Where is this restriction, in IIS or something?
UPDATE: my code on server continue to run in the background and receives the whole file even though the caller of the service gets 'bad gateway'. So this is a 'false' 502.
I have created a Workflow service using Microsoft WF (https://msdn.microsoft.com/en-us/library/ff432975%28v=vs.110%29.aspx)
When i run the service in visual studio I'm getting the below error
Error: Cannot obtain Metadata from http://localhost/OrderService/Service1.xamlx
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.
For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost/OrderService/Service1.xamlx
Metadata contains a reference that cannot be resolved: 'http://localhost/OrderService/Service1.xamlx'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error URI: http://localhost/OrderService/Service1.xamlx
There was an error downloading 'http://localhost/OrderService/Service1.xamlx'. The request failed with an empty response.
My config is below. I have added the Meta Exchange lines in the config file also.
<system.serviceModel>
<services>
<service behaviorConfiguration="metadataBehavior" name="MyService">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<!--Connection String for the WF SQL Presistance-->
<sqlWorkflowInstanceStore connectionString="Data Source=AAAAA;Initial Catalog=KK_SQLPersistenceStore;Asynchronous Processing=True" instanceEncodingOption="None" instanceCompletionAction="DeleteAll" instanceLockedExceptionAction="BasicRetry" hostLockRenewalPeriod="00:00:30" runnableInstancesDetectionPeriod="00:00:02" />
<workflowIdle timeToUnload="0"/>
</behavior>
</serviceBehaviors>
</behaviors>
Try changing you endpoint address to this
<endpoint address="http://localhost/OrderService/Service1.xamlx/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
I have a WCF Service Library which is run as a windows service. I would like to migrate this service as Azure worker role. When I right click on a WCF project, I typically see the option "Add Windows Azure Deployment Project". With my WCF library, I do not see this option. In that case, how do I migrate the WCF service library to Azure as worker role? Any help would be greatly appreciated.
Below is the app.config for my WCF service library.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IHealthService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:9017/monitor/health/service.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IHealthService"
contract="HealthService.IHealthService" name="NetTcpBinding_IHealthService" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
In this case, I would like to suggest you to manually create a worker role project, add a reference to the service library project, and then host the service inside the worker role. The service host code is similar to what you get for a normal console/Windows Service host. But please obtain the address via code. In addition, you can refer to http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_WindowsAzureRoleCommunicationVS2010Lab for a complete tutorial.
Best Regards,
Ming Xu.
The Add Windows Azure Deployment Project option only appears if the project type is a WebApplication or WCF Application. You have to host your WCF library in a WebApplication and then the option will appear (or even better host it directly in a Windows Azure WebRole project).
If you really want to host your WCF library in a WorkerRole I suggest you do what Ming Xu has explained. But normally you host your WCF services in WebRoles on Windows Azure. So I hope you have a special need that explains why you want to use WorkerRoles.
I hope that helps.
I'm doing a iCal Service to allow sync between Calendar instances and runs fantastic on localhost (under VS2010 Web Server)
But now That I hosted on a Windows 2008 R2 (IIS 7.5.7600) I couldn't create not even update an event :-o
Thunderbird always said
So I rush into Fiddler and found out the problem
a 405 error
That says PUT is not allowed :(
How can I enabled this method? Application Pool? WebSite definition? IIS Settings?
We just need to remove the WebDav Service
Control Panel > Program and Features > Turn Windows features on or off
then navigate to Server Manager > Roles > Web Server (IIS) and wait until Roles Services come up.
Then Remove Role Service and Remove WebDAV Publishing
You need to restart the Server to finalize this action.
I hope it helps someone
You can do it from configuration file.
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"
path="*."
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
preCondition="classicMode,runtimeVersionv4.0,bitness64"
responseBufferLimit="0" />
</handlers>
</system.webServer>
Source: http://www.asp.net/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications