I am trying to test an MVC application that uses WCF web service. It works fine when I run it using the dev server in VS2010. However when I deploy it on IIS7 and try to invoke any service method in my controller code I get the following error:
(405) Method Not Allowed
Does anyone know how to resolve this issue?
My web config entries as follows:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAuthenticationService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://SiteName/ServiceName/AuthenticationService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAuthenticationService"
contract="AuthService.IAuthenticationService" name="BasicHttpBinding_IAuthenticationService">
</endpoint>
</client>
</system.serviceModel>
sounds like the old "ASP.NET is not installed or register to your IIS" problemo Try registering it using
aspnet_regiis –i –enable
from a command prompt run under admin rights.
Duh...the WCF service and the MVC app had mismatched .NET versions! :( silly me.
Related
Web.config on dev calls a Web service on another remote dev server hence the binding looks like this
<binding name="XXXSoap12">
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="1048576" allowCookies="false"
authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true"
hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="1048576"
proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
I want to change the httpTransport protocol/tag to httpsTransport protocol for QA, STG & PROD.
How do I write a transform for the same.
In Web.Release.config (or Web.QA.config, or Web.STG.config, or another transform):
<binding name="XXXSoap12">
<httpTransport xdt:Transform="Remove" />
<httpsTransport xdt:Transform="Insert"
manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="1048576" allowCookies="false"
authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true"
hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="1048576"
proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
You can also read this to learn more about config transforms.
I've got an WCF .svc file added to my MVC3 project and I'm trying to prevent the service being accessed over HTTP.
With the config below my service is available over https on one port and then over http on another.
How can I prevent this?
Thanks
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="TS">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Endpoints" behaviorConfiguration="Default">
<endpoint address="https://localhost:44301/Services/Endpoints.svc" binding="basicHttpBinding" bindingConfiguration="TS" contract="UkerLtd.Services.IEndpoints"></endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="false" httpsGetUrl="https://localhost:44301/Services/Endpoints.svc" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
You can comment or remove the second endpoint for the IMetadataExchange,
since it is for the same service, the metadata will be exposed by the
httpsGetEnabled="true" in the serviceBehaviors/serviceMetadata.
Otherwise you could "Set up IIS to require SSL", but since it's not an option..
hope this helps.
When I update a Service Reference I end up with :
An endpoint configuration section for contract 'MyService.MainServiceSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
my web.config ends up like this:
endpoints:
<endpoint address="http://localhost/main/MainService.asmx"
binding="basicHttpBinding" bindingConfiguration="MainServiceSoap"
contract="MyService.MainServiceSoap" name="MainServiceSoap" />
<endpoint address="http://localhost/main/MainService.asmx"
binding="customBinding" bindingConfiguration="MainServiceSoap12"
contract="MyService.MainServiceSoap" name="MainServiceSoap12" />
bindings:
<basicHttpBinding>
<binding name="MainServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="655360" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="81920" maxArrayLength="163840"
maxBytesPerRead="40960" maxNameTableCharCount="163840" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="MainServiceSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
I manually delete customBinding and Soap12 endpoint and everything works fine. But if I update the service again (right click Update Service Reference) the added custom binding is added again causing error and the need to manually remove from config file.
Does someone knows how to fix this ? I don't want/need a custom soap12 binding.
This is the service config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<globalization culture="es-PY" uiCulture="es-PY"/>
<customErrors mode="Off"/>
<webServices>
<!-- Tried adding and/or removing protocols and conformanceWarnings -->
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
<!-- -->
<conformanceWarnings>
<remove name="BasicProfile1_1"/>
</conformanceWarnings>
</webServices>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="standard" maxReceivedMessageSize="6553600" maxBufferSize="6553600" transferMode="Streamed" helpEnabled="true" automaticFormatSelectionEnabled="true">
<readerQuotas maxStringContentLength="65536000" maxArrayLength="163840" />
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above 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"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Tried setting multipleSiteBindingEnalbed true and false -->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<!-- -->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<connectionStrings>
<clear/>
<add name="GamblingEntities" connectionString="..." providerName="System.Data.EntityClient" />
<add name="GamblingSiteEntities" connectionString="..." providerName="System.Data.EntityClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<clear/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
</configuration>
The new ASMX runtime in .NET 2.0 supports SOAP 1.2. At this moment SOAP 1.1 is most widely being used in the industry. In the .NET Framework both SOAP 1.1 and SOAP 1.2 are supported. This means that the Web Services created in .NET Framework 2.0 will be configured to support both SOAP 1.1 and SOAP 1.2 messages. This indirectly means that the WSDLs thus created for the Web Service will have two types of bindings, i.e., SOAP 1.1 and SOAP 1.2.
Taken from here
This is why two bindings are being generated.
<remove name="HttpSoap12"/>
I guess this i how you disable this now i can understand why you see this as a workaround.
Something may have caused this when you moved your web service to the new framework and this is why some of your older web services on 1.1 possibly don't respond in the same way.
Try targeting 2.0 framework maybe to see what happens.
There is no solid workaround. I voted up your question. I am a victim of same problem, Although now I switched to generating dll using svcutil but this issue has been reported to Microsoft here update-or-configure-an-existing-service-reference-in-sl-application-you-get-duplicate-binding-and-endpoint-information
They said, it's fixed in VS2010 but I confirm it's not, I have VS2010 SP1 installed too but this is not fixed in SP1 also. So there this no fix given and bug is closed as 'External'. strange.
On the bug report page, you can also find a workaround but I find that messy.
Another workaround is creating service client object with binding name hard-coded to avoid double endpoint
MyService.MainServiceSoap mainServiceSoap = new MyService.MainServiceSoap("MainServiceSoap");
or at last we can open another bug report at Microsoft and vote up to fix it.
I just call svcutil.exe manually to rebuild my proxy class. Much simpler.
I have a somewhat long-taking WCF-based process. WCF service runs in Azure if its of any help. The issue I believe has to do with timeouts:
1) Winforms client has the following .config setting in the binding section:
<wsHttpBinding>
<binding name="XXX" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="255" 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" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
2) WCF service has the following binding section in the web.config
<wsHttpBinding>
<binding name="XXX" maxReceivedMessageSize="10000000" sendTimeout="00:10:00" receiveTimeout="00:10:00" closeTimeout="00:10:00" openTimeout="00:10:00">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
<readerQuotas maxArrayLength="2000000" maxBytesPerRead="10000000" maxStringContentLength="10000000" maxDepth="255" />
</binding>
</wsHttpBinding>
3) I have one long-running method in WCF (generally 2 minutes). Clients call the method, and those that execute for longer then 1 minute are getting thrown out with an exception. This is the most inner exception:
<InnerException>
<Type>System.Net.Sockets.SocketException</Type>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
<Frame>at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</Frame>
</StackTrace>
</InnerException>
</InnerException>
4) The WCF call itself completed successfully, however (I have both Start/End logged on server side). How do I avoid the exception?
Thank you!
The Windows Azure load balancer terminates idle connections after 60 seconds.
Check out the latest post from Azure team... http://azure.microsoft.com/blog/2014/08/14/new-configurable-idle-timeout-for-azure-load-balancer/
Updated answer:
Azure load balancer terminates idle connections after 4 minutes. If you're interested in increasing/decreasing timeout value, check this article:
https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/
I have a WCF .svc file hosted in IIS. I want to use basicHTTP binding. This services job is to actually call another service over net.tcp. Everything works fine locally, but when I deployed, I'm getting this error.
The provided URI scheme 'http' is
invalid; expected 'net.tcp'. Parameter
name: via
Here is the server config
<client>
<endpoint address="net.tcp://localhost:9300/InternalInterfaceService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IInternalInterfaceService"
contract="IInternalInterfaceService" name="NetTcpBinding_IInternalInterfaceService">
<identity>
<servicePrincipalName value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="MyExternalService">
<endpoint address="" binding="basicHttpBinding" contract="IMyExternalService" />
</service>
</services>
And here is the config that svcutil generates
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyExternalService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myserver.somesdomain.com/Services/MyExternalService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyExternalService"
contract="IMyInternalService" name="BasicHttpBinding_IMyExternalService" />
</client>
</system.serviceModel>
What do I need to do to wire this up correctly. I do not want to expose InternalInterfaceService over http. What am I doing incorrectly here? Any tips or suggestions are certainly appreciated.
Thanks,
~ck
You need a routing service - one that exposes a HTTP endpoint to the world, and uses netTcp internally.
Basically, your outward facing http service must become a client in turn to call the internal netTcp service.
You can definitely do this in .NET 3.5 with a bit of effort:
Service Station: Building a WCF Router, Part 1
Service Station: Building a WCF Router, Part 2
or you can use the new WCF 4 Routing Service in .NET 4 / VS 2010:
Creating Routing Service using WCF 4.0, .NET Framework 4.0 and Visual Studio 2010
WCF in .NET 4 the WCF Routing service