I have a WCF application hosted as a webrole in Azure with the following configuration. I am getting a 400 Bad Request when trying to access any of the three service wsdl in a browser or when trying to set up a proxy.
<?xml version="1.0"?>
<configuration>
<appSettings>
</appSettings>
<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings></connectionStrings>
<system.diagnostics>
<sharedListeners>
<add name="AzureLocalStorage" type="Example.AzureLocalStorageTraceListener, Example"/>
</sharedListeners>
<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureLocalStorage" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="AzureLocalStorage" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="MetaBehavior">
<endpoint address="http://example.com/service1.svc" binding="basicHttpBinding" name="basicEndpoint1" contract="IService1" />
</service>
<service name="Service2" behaviorConfiguration="MetaBehavior">
<endpoint address="http://example.com/service2.svc" binding="basicHttpBinding" name="basicEndpoint2" contract="IService2" />
</service>
<service name="Service3" behaviorConfiguration="MetaBehavior">
<endpoint address="http://pexample.com/service3.svc" binding="basicHttpBinding" name="basicEndpoint3" contract="IService3" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetaBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true"/>
<serviceThrottling maxConcurrentSessions="90" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I am pretty sure my configuration is not right but I need a little guidance with what is incorrect.
An interface is defined as:
[ServiceContract(Name = "Service1", Namespace = "http://example.com")]
public interface IService1
{
[WebGet]
[OperationContract]
Result Create();
}
You’re using the wrong binding, try webHttpBinding instead of basicHttpBinding. Your contract is set to WebGet which is WCF’s take on a quasi-REST based service. BasicHttpBinding is only for soap based bindings (hence the “Bad request” exception).
EDIT:
Since the
WebGetwas present, I assumed you didn’t want soap endpoints. Below is a config that supports both soap and WebGet. I don’t know how different Azure is from standard IIS but you should probably use relative addresses for your service. IIS will only support relative addresses in the service config.