Contains an unrecognized http body format value 'Xml' - c#

There are a number of similar questions on stack overflow, but none have helped me formulate a solution.
Question below is the closest, but I couldn't get it to work and my other services stopped working when I tried to implement it.
WCF input huge XML as Stream with Content-Type: xml/text
Error: Incoming message for operation 'IncomingXML' (contract ... with namespace ...) contains an unrecognized http body format value 'Xml'. The expected body format value is 'Raw'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.
Basically I need this and only this web service to accept "application/xml". At the moment it accepts only "raw", the service fails when the call has "application/xml" set.
The problem is two parts, one allow the service to accept xml and two, don't effect the other web services. This is the only service that accepts incoming xml.
Does anyone have any suggestions? If I can't get this to work without disrupting the other web services.
Contract
[OperationContract]
[WebInvoke(Method = "POST")]
void IncomingXML(Stream xml);
Service
public void IncomingXML(Stream xml)
{
}
Web.config:
<system.serviceModel>
<extensions>
...
</extensions>
<diagnostics>
...
</diagnostics>
<behaviors>
<endpointBehaviors>
<behavior name="jsonEndpointBehavior">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" defaultBodyStyle="WrappedRequest" faultExceptionEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<endpointDiscovery enabled="true" />
</behavior>
<behavior name="xmlEndpointBehavior">
<webHttp helpEnabled="false" defaultBodyStyle="WrappedRequest" defaultOutgoingResponseFormat="Xml" automaticFormatSelectionEnabled="true" faultExceptionEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="rawEndpointBehavior">
<webHttp helpEnabled="false" defaultBodyStyle="WrappedRequest" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" faultExceptionEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="jsonBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true" />
<binding name="jsonsBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="xmlBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true" />
<binding name="xmlsBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="rawBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true" />
<binding name="rawsBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" crossDomainScriptAccessEnabled="true">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="soapBinding" />
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehavior" name="Namespace.Web.WCF.Service">
<endpoint address="json" behaviorConfiguration="jsonEndpointBehavior" binding="webHttpBinding" bindingConfiguration="jsonBinding" name="jsonHttpEndpoint" bindingName="Namespace.Service.JsonHttp" contract="Namespace.Web.WCF.IService" />
<endpoint address="json" behaviorConfiguration="jsonEndpointBehavior" binding="webHttpBinding" bindingConfiguration="jsonsBinding" name="jsonHttpsEndpoint" bindingName="Namespace.Service.JsonHttps" contract="Namespace.Web.WCF.IService" />
<endpoint address="xml" behaviorConfiguration="xmlEndpointBehavior" binding="webHttpBinding" bindingConfiguration="xmlBinding" name="xmlHttpEndpoint" bindingName="Namespace.Service.XmlHttp" contract="Namespace.Web.WCF.IService" />
<endpoint address="xml" behaviorConfiguration="xmlEndpointBehavior" binding="webHttpBinding" bindingConfiguration="xmlsBinding" name="xmlHttpsEndpoint" bindingName="Namespace.Service.XmlHttps" contract="Namespace.Web.WCF.IService" />
<endpoint address="" behaviorConfiguration="xmlEndpointBehavior" binding="webHttpBinding" bindingConfiguration="rawBinding" name="rawHttpEndpoint" bindingName="Namespace.Service.RawHttp" contract="Namespace.Web.WCF.IService" />
<endpoint address="" behaviorConfiguration="xmlEndpointBehavior" binding="webHttpBinding" bindingConfiguration="rawsBinding" name="rawHttpsEndpoint" bindingName="Namespace.Service.RawHttps" contract="Namespace.Web.WCF.IService" />
<endpoint address="web" binding="basicHttpBinding" bindingName="Namespace.Service" contract="Namespace.Web.WCF.IService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>

This blog post has the solution: http://kimcuhoang.blogspot.be/2011/04/solving-raw-issue-with-wcf-and-content_13.html
Basically you have to override the default web message encoding
Create a custom mapper:
public class RawContentTypeMapper : WebContentTypeMapper
{
public override WebContentFormat GetMessageFormatForContentType(string contentType)
{
if (contentType.Contains("text/xml") || contentType.Contains("application/xml"))
{
return WebContentFormat.Raw;
}
else
{
return WebContentFormat.Default;
}
}
}
Then refer to it in the binding configuration:
<service behaviorConfiguration="NotificationServiceBehavior" name="AtlanticGateway.GatewayComponent.Services.NotificationService">
<endpoint behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" contract="AtlanticGateway.GatewayComponent.Message.INotificationService" />
<bindings>
<customBinding>
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="AtlanticGateway.GatewayComponent.RawContentTypeMapper, AtlanticGateway.GatewayComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
...

Related

404 - Error: Getting Empty response from WCF Service is giving Error in Azure

From Azure it is giving, when I try to post to: https://wcf/service.svc/json/DoAction it comes back with an empty response.
Below is the webconfig
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="SampleService" behaviorConfiguration="ChallengeBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="ChallengeMessageEncoding" contract="IService123" behaviorConfiguration="SoapServiceBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfigu**strong text**ration="RestServiceMessageEncoding" contract="ISampleService" behaviorConfiguration="RestServiceBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
</behavior>
<behavior name="SoapServiceBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RestServiceMessageEncoding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="ChallengeMessageEncoding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
Enable the features of WCF in Add or remove programs in your local or in VM of Azure.

Using WCF CustomBinding SOAP 1.1

Convert wsHttpBinding SOAP 1.2 to BindingCustom SOAP 1.1
Code Web.config tag wsHttpBinding:
<wsHttpBinding>
<binding name="ServiceBinding" allowCookies="true" closeTimeout="01:01:50" openTimeout="01:01:05" receiveTimeout="01:10:05" sendTimeout="01:01:05" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
tag CustomBinding:
<customBinding>
<binding name="WsHttpSoap11" >
<security authenticationMode="CertificateOverTransport" />
<textMessageEncoding messageVersion="Soap11WSAddressing10" maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" />
<httpsTransport authenticationScheme="None" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
Continuation of the code web.config:
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfPecuaria.Service">
<endpoint name="ServiceBinding" contract="WcfPecuaria.IService" address="" binding="customBinding" bindingConfiguration="WsHttpSoap11" behaviorConfiguration="WsdlEndpointBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WsdlEndpointBehavior">
<wsdlExtensions location="https://dominio.br/PecuariaWCFH/Service1.svc" singleFile="true"/>
<!--<wsdlExtensions location="http://localhost:44339/Service1.svc" singleFile="true"/> -->
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" includeWindowsGroups="false" customUserNamePasswordValidatorType="CustomUserNameValidator.CustomUserNameValidator,App_Code" />
<clientCertificate>
<authentication customCertificateValidatorType="CustomUserNameValidator.CustomCertificateValidator,App_Code" certificateValidationMode="Custom" includeWindowsGroups="false" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
Making request in SoapUI in any method I have the error response:
HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-
8;action="http://tempuri.org/ServiceContract/SendBuscaLotes"' was not the expected type 'text/xml;
charset=utf-8'.
Server: Microsoft-IIS/8.5
Date: Wed, 11 Mar 2020 12:10:39 GMT
Content-Length: 0
Terrific. Given that you have solved this type of issue by yourself, I want to give a common solution to this. How to transform the built-in system-binding to custom binding?
Please refer to the below code segments.
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
//Iterate over all binding elements constructed the binding.
foreach (var item in binding.CreateBindingElements())
{
Console.WriteLine(item.ToString());
}
Result.
Then we can construct the custom binding,
<customBinding>
<binding name="WsHttpSoap11" >
<transactionFlow/>
<textMessageEncoding />
<httpsTransport/>
</binding>
</customBinding>
Feel free to let me know if there is anything I can help with.

Windows Service (413) Request Entity Too Large

Please do not delete this as a duplicate
I have a windows service that I am passing an array of objects to. When the array contains less than 150 objects it works successfully. When I pass more than 150 objects I get the (413) Request Entity Too Large Error.
I have tried the feedback from other articles regarding readerQuotas node values and maxReceivedMessageSize, but I am still receiving the error and I am stuck as to what I am still doing wrong.
Here is the app.config of the windows service:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingNoSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None"/>
<message establishSecurityContext="false" negotiateServiceCredential="false"/>
</security>
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SE.Responder.Integration.AmiOutboundService.AmiObService" behaviorConfiguration="Service1Behavior">
<endpoint address="wsHttp" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" name="basicHttp" contract="SE.Responder.Integration.AmiOutboundService.IAmiObService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
And here is the app.config of the executable that passes the data to the windows service:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAmiObService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/SE.Responder.Integration.AmiOutboundService/AmiObService/AmiOBService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAmiObService" contract="AmiObService.IAmiObService" name="WSHttpBinding_IAmiObService" />
</client>
After reviewing the source code for the application that was having this issue, I found that the wcf service was being hosted in the C# code. I then applied the fix in code as described in the following stack overflow issue,
MaxReceivedMessageSize in WCF Hosted Service in console application,
specifically the following lines,
var wsHttpBinding = new WSHttpBinding();
wsHttpBinding.MaxReceivedMessageSize = int.MaxValue;
Service.AddServiceEndpoint(typeof(TInterfaceContract), wsHttpBinding, EndpointAddress);
which corrected the issue.

WCF Error - 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'

I have facing above error after adding the maxItemsInObjectGraph="2147483647" parameter both server and client.
However in my project large number of data can transferred using "datatable" objects without any issue.
This error occurred large number of data transferred with using "List<>" objects.
My dotnetframework is 4.0, but I found this error NOT found in dotnetframework 4.5 and large number of data can transferring using "List<>" object without error. Also this is Windows base project.
Please anyone can solved this problem. Here are the my server and client app.cofig configurations.
Thanks!!!
My Service;
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling
maxConcurrentSessions="1200"
maxConcurrentCalls="192"
maxConcurrentInstances="1392"
/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding maxReceivedMessageSize="2147483647" name="netTcpBinding" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehavior" name="MyBLL">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBinding" name="MyEndPoint" contract="IMy">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/MySVC"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
My Client;
<system.serviceModel>
<client>
<endpoint name="MyEndPoint" address="net.tcp://localhost:8000/MySVC" binding="netTcpBinding" bindingConfiguration="netTcpBinding" contract="IMy" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" maxReceivedMessageSize="2147483647" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehavior" name="MyEndPoint">
<endpoint address="" behaviorConfiguration="CommonBehavior" binding="netTcpBinding" bindingConfiguration="netTcpBinding" name="MyEndPoint" contract="Imy">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/MySVC" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Finally I found my mistake in client config and I was solved my problem.
My mistake was behaviorConfiguration="CommonBehavior" tag not in the client, endpoint section. After added this part the problem was successfully solved and large number of records exist generic list I can transferred from server to client.
This is my corrected client config -
<system.serviceModel>
<client>
<endpoint name="MyEndPoint" behaviorConfiguration="CommonBehavior" address="net.tcp://localhost:8000/MySVC" binding="netTcpBinding" bindingConfiguration="netTcpBinding" contract="IMy" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" maxReceivedMessageSize="2147483647" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>

Is this WCF configuration causing my 400 bad request?

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 WebGet was 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.
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="Service.Behavior">
<endpoint address="Service1"
binding="basicHttpBinding"
contract="IService1"
bindingNamespace = "http://example.com"
bindingConfiguration="HttpBasic" />
<endpoint address="mexService1"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingNamespace = "http://example.com"/>
<endpoint address="webService1"
binding="webHttpBinding"
behaviorConfiguration="webBehavior"
contract="IService1"
bindingNamespace = "http://example.com"
name="webHttp"
listenUriMode="Explicit" />
</service>
<service name="Service2" behaviorConfiguration="Service.Behavior">
<endpoint address="Service2"
binding="wsHttpBinding"
contract="IService2"
bindingNamespace = "http://example.com"
bindingConfiguration="HttpStandard" />
<endpoint address="mexService2"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingNamespace = "http://example.com"/>
<endpoint address="webService2"
binding="webHttpBinding"
behaviorConfiguration="webBehavior"
contract="IService2"
bindingNamespace = "http://example.com"
name="webHttp"
listenUriMode="Explicit" />
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior" >
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Service.Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="HttpBasic" receiveTimeout="00:10:00" maxReceivedMessageSize="2048000">
<security mode="None"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="HttpStandard" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="None" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
</security>
</binding>
<binding name="Https" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="None" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
</security>
</binding>
<binding name="HttpsAuthenticated" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000">
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>

Categories