Have a WCF service that I am trying to add configuration for REST to. Keep getting the AddressFilter mismatch error. I have tried all the suggestions and gone over the addresses several times but I must be missing something in my configuration. Was hoping someone with some more experience with REST could see what I am missing here.
My service configuration is the following:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="www.parinc.com.PARToolkit">
<endpoint address="" binding="wsHttpBinding" contract="IPARToolkit"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="rest" binding="webHttpBinding" contract="IPARToolkit" behaviorConfiguration="webBehavior" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:86/" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" />
</protocolMapping>
The contract is set up as:
[OperationContract]
[WebInvoke(UriTemplate = "GetApps?authKey1={authKey1}&authKey2={authKey2}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetApps(string authKey1, string authKey2);
But when I try calling the service as follows (without the spaces I put in http to get the url to post here) I get the AddressFilter mismatch error:
"http://localhost:86/WebServices/PARToolkit.svc/rest/GetApps?authKey1=12345&authKey2=56789"
if you host the service in IIS, then remove the 'rest' in your address. e.g.
h t t p://localhost:86/WebServices/PARToolkit.svc/GetApps?authKey1=12345&authKey2=56789
and also, in service configuration, no need for address in endpoint. e.g.
<endpoint address="" binding="webHttpBinding" contract="IPARToolkit" behaviorConfiguration="webBehavior" />
and remove the baseAddresses sections.
Related
I have this WCF service with a SOAP endpoint and I'm succesfully exposing both methods with the following code/config:
Service Contract
[ServiceContract]
public interface IService
{
[OperationContract]
string TestConn();
[OperationContract]
string AddRecord();
}
Web.config
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WSADPITG.Service" behaviorConfiguration="ServiceBehavior">
<endpoint binding="basicHttpBinding" contract="WSADPITG.IService" address="" name="WSADPITG" />
<endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex" />
</service>
</services>
Is it possible to add a REST endpoint to expose ONLY TestConn method? What changes in code/config?
You should separate contracts,because single service can have single behavior.Hence two services should be host in your single web.config file.
WCF REST Service
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet]
string TestConn();
}
Now the configuration file.
<system.serviceModel>
<behaviors>
<serviceBehaviors >
<behavior name="ServiceBehavior">
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="ServiceClassNamespace.YourServiceClasImplementation" behaviorConfiguration="ServiceBehavior">
<endpoint binding="webHttpBinding" contract="ServiceClassNamespace.IService" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Pure WCF Service
[ServiceContract]
public interface IService2
{
[OperationContract]
string AddRecord();
}
Your above mentioned web.config must be appended to the existing(WCF REST) config file.
<system.serviceModel>
<behaviors>
<serviceBehaviors >
<behavior name="ServiceBehavior">
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="ServiceClassNamespace.YourServiceClasImplementation" behaviorConfiguration="ServiceBehavior">
<endpoint binding="webHttpBinding" contract="ServiceClassNamespace.IService" behaviorConfiguration="web">
</endpoint>
</service>
<service name="WSADPITG.Service" behaviorConfiguration="ServiceBehavior">
<endpoint binding="basicHttpBinding" contract="WSADPITG.IService2" address="" name="WSADPITG" />
<endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex" />
<host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Where in the web.config should the following blocks of code go for a WCF RESTful service?
<endpoint address="" binding="webHttpBinding"contract="Wcf_Test.IMyService"
behaviorConfiguration="httpEndpointBehavour">
<identity>
<dns value="localhost"/>
<Identity>
</endpoint>
and
<behaviors>
<serviceBehaviors>
<behavior name="httpBehaviour"> <serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
and
<endpointBehaviors>
<behavior name="httpEndpointBehavour">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
In order to configure a WCF REST service, you need a few things in your web.config file
1) Declare your service and its endpoint
<services>
<service name="SparqlService.SparqlService" behaviorConfiguration="ServiceBehavior">
<endpoint binding="webHttpBinding" contract="SparqlService.ISparqlService"
behaviorConfiguration="webHttp"/>
</service>
</services>
Service name will be [project name].[service name]
Behavior configuration will be same name as the behavior you declare in the next step
Binding must be webHttpBinding because you want it as REST. If you want SOAP, you declare as basicHttpBinding
Contract is the [project name].[interface name]
Behavior configuration in the endpoint will be the name you declare in next step
2) Declare the service behavior (usually default)
<behavior name="ServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
Behavior name can be anything, but it will be used to match BehaviorConfiguration you declared in step 1
Leave the rest alone
3) Declare your endpoint behavior
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
Behavior name can be anything, but it will be used to match the behaviorConfiguration in endpoint.
In the end, this is what the web.config should look like for a simple REST service:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="SparqlService.SparqlService" behaviorConfiguration="ServiceBehavior">
<endpoint binding="webHttpBinding" contract="SparqlService.ISparqlService"
behaviorConfiguration="webHttp"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<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="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
for the rest type using WCFservice
<configuration>
<system.serviceModel>
<services>
<service>
<--
"place the first code snippet here "
it will contain the endpoint details
for WCFrestfulServices it will have 'A' ,'B' and 'C'
that is address, binding and contract
-->
</service>
</services>
<behaviors>
<servicebehaviours>
<--
"place the second code snippet"
the name of the behavior should be the same to that of the
behavior configuration attribute value of service tag
-->
</servicebehaviours>
<endpointBehaviors>
<--
"place your third code snippet"
the name of the behavior should be the same to that of the
behavior configuration attribute value of endpoint tag
-->
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Web config changes.
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint address="" behaviorConfiguration="restbehavior" binding="webHttpBinding" bindingConfiguration=""
contract ="WcfService1.IBookService">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost/bookservice"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restbehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Interface: we have to use WebGet for httpGet / WebInvoke for HttpPost & Put & Delete.
[ServiceContract]
public interface IBookService
{
[OperationContract]
[WebGet]
List<BOOK> GetBooksList();
[OperationContract]
[WebGet(UriTemplate = "Book/{id}")]
BOOK GetBookById(string id);
[OperationContract]
[WebInvoke(UriTemplate = "AddBook/{name}")]
void AddBook(string name);
}
Ref : https://www.codeproject.com/Articles/571813/A-Beginners-Tutorial-on-Creating-WCF-REST-Services
I am yrying to have the same contract and service to be exposed as both basicHttpBinding and webHttpBinding to be able to do a POST call. somehow it's NEVER seeing the endpoint for webHttpBinding when I look at the wsdl. What I am doing wrong?
<system.serviceModel>
<services>
<service name="MyService">
<endpoint address =""
binding="basicHttpBinding"
name="EndpointBasic"
contract="IMyService"/>
<endpoint address ="PostMethod"
binding="webHttpBinding"
name="EndpointJson"
contract="IMyService"/>
<host>
<baseAddresses>
<add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" />
</basicHttpBinding>
<webHttpBinding>
<binding name="Postbinding"
maxBufferSize="65536"
maxReceivedMessageSize="2000000000"
transferMode="Streamed">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Thanks!
I have the following service element entry which works for both SOAP and REST:
<service name="XMLService.RestAndSoapService" behaviorConfiguration="default">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="RestBinding" name="SampleService" contract="XMLService.IRestAndSoapService" />
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="noSecurity" contract="XMLService.IRestAndSoapService" />
</service>
Points to note in your config:
In your service element your contract and service name are not fully qualified. Make sure that they are fully qualified ie. includes the namespace along with the interface.
You have not specified the bindingConfiguration as "Postbinding" for webHttpEndpoint and "basicBinding" for basicHttpBinding endpoint
So with the above changes your config might look as shown below:
<service name="namespace.MyService">
<endpoint address =""
bindingConfiguration="basicBinding"
binding="basicHttpBinding"
name="EndpointBasic"
contract="namespace.IMyService"/>
<endpoint address ="PostMethod"
bindingConfiguration="Postbinding"
binding="webHttpBinding"
name="EndpointJson"
contract="namespace.IMyService"/>
<host>
<baseAddresses>
<add baseAddress ="http://localhost/WebsiteName/MyService.svc"/>
</baseAddresses>
</host>
</service>
Any ideas how I correct this.. calling a service via js
The message with To 'http://MySite.svc/GetStateXML' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree
thanks
The error listed below indicates that the Web Service implements WS-Addressing.
"The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree"
Include the following in your SOAP Headers to access the Web Service:
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://example.com/service</wsa:To>
</soap:Header>
I just ran into this as well while going through an example in the Learning WCF book by Bustamante.
I had used the WCF Config Editor to fill out my config on my host and had put the value in the name attribute for my endpoint rather than the address attribute. Once I fixed it things worked.
I found another post that suggested using:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
on the implementation class, which worked but wasn't the root cause.
Bottom line appears to be: make sure your client and server configs match.
I got this error while I was using webHttpBinding.
I resolved it by adding
<endpointBehaviors>
<behavior name="EndPointBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
under <behaviors> and setting behaviorConfiguration="EndPointBehavior" in my endpoint with binding="webHttpBinding".
Full config:
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndPointBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="ServiceBehavior">
<endpoint address=""
binding="webHttpBinding"
contract="WcfService1.IService1"
behaviorConfiguration="EndPointBehavior">
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
I know it sounds silly but for anyone else that has this error check your address. We were getting this error because we had a double slash where there should have only been one.
http://localhost//servicename.svc
The above address caused the problem.
http://localhost/servicename.svc
Did not exhibit the problem.
We were dynamically creating the full address from parts of data read in from windows forms and a database. The user was entering /servicename.svc instead of servicename.svc
I had this issue in my development environment for a web service hosted in IIS. Solved it by going to 'IIS Manager' and added a binding to the host name complained about in the error message.
Add webHttp attribute to your config:
endpointBehaviors
behavior name ="yourServiceContract"
webHttp automaticFormatSelectionEnabled ="true "
behavior
I had the same kind of issue, just to be complete :
I used visual studio 2017
I needed to create a wcf service on an old application using .net 3.5
It should be exposed as a soap service and as a "Rest" service
the configuration that I needed to use (for rest part) was :
there is a config for the service behaviour and the endpoint behaviour
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webEndpointBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="My.Service" behaviorConfiguration="myServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="My.IService" behaviorConfiguration="webEndpointBehaviour">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
In my case I have WCF Service library application which is a RESTFul and Windows Service Host. I had problem with Host App.Config. Please see below
WCF Rest Service App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="MyService.DocumentWCFRESTService" behaviorConfiguration="defaultServiceBehavior">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="http://localhost:2023/DocumentWCFRESTService"
binding="webHttpBinding" behaviorConfiguration="webBehaviorConfiguration"
contract="MyService.IDocumentWCFRESTService" >
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/Document.Server.WCFREST.Service/DocumentWCFRESTService/" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings> </bindings>
<behaviors>
<serviceBehaviors>
<behavior name="defaultServiceBehavior">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:2023/DocumentWCFRESTService"/>
<!-- 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>
<endpointBehaviors>
<behavior name="webBehaviorConfiguration">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Windows Service Host App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingConfiguration" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="documentWCFRESTServiceBehavior">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:2023/DocumentWCFRESTService"/>
<!-- 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>
<endpointBehaviors>
<behavior name="webBehaviorConfiguration">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyService.DocumentWCFRESTService" behaviorConfiguration="documentWCFRESTServiceBehavior">
<endpoint address="http://localhost:2023/DocumentWCFRESTService" behaviorConfiguration="webBehaviorConfiguration"
binding="webHttpBinding" bindingConfiguration="webHttpBindingConfiguration"
contract="MyService.IDocumentWCFRESTService"></endpoint>
</service>
</services>
</system.serviceModel>
</configuration>
if you have multiple endpoints in your WCFService.config like:
<endpoint address="urn:Service.Test" .../>
<endpoint address="urn:Service.Test2".../>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:1234/Service/" />
<add baseAddress="http://localhost:1233/Service/" />
<add baseAddress="net.pipe://localhost/Service/" />
</baseAddresses>
</host>
You need to set EndpointAddress like in your config file.
Then you need ClientViaBehavior for the baseAddress.
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
EndpointAddress address = new EndpointAddress("urn:Service.Test");
AndonClient client = new AndonClient(binding, address);
client.ChannelFactory.Endpoint.EndpointBehaviors.Add(new ClientViaBehavior(new Uri("net.tcp://localhost:1234/Service/Test")));
var response = client.GetDataAsync().Result;
For .net core you need to write the Behavior by yourself:
public class ClientViaBehavior : IEndpointBehavior
{
Uri uri;
public ClientViaBehavior(Uri uri)
{
if (uri == null)
throw new ArgumentNullException(nameof(uri));
this.uri = uri;
}
public Uri Uri
{
get { return this.uri; }
set
{
if (value == null)
throw new ArgumentNullException(nameof(value));
this.uri = value;
}
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
if (clientRuntime == null)
{
throw new ArgumentNullException(nameof(clientRuntime));
}
clientRuntime.Via = this.Uri;
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
throw new NotImplementedException();
}
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
{
}
}
I had a similar problem.
The following address was provided to the client:
https://test.mycompany.ru/ChannelService/api/connect.svc
But according to the logs, the client sent requests to the following address:
https://test.mycompany.ru/ChannelService/api/connect.svc/SOAP/Adapter
After I added the endpoint address to the configuration file, the service started working:
<services>
<service name="connect">
<endpoint address="/SOAP/Adapter"
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="IContract">
</endpoint>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
</service>
</services>
The key elements are the webHttp and binding="webHttpBinding" for the Json work in the browser test. However SoapUI still failed to return JSon.
Look at <webHttp />
<services>
<service name="SimpleService.SimpleService" behaviorConfiguration="serviceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="SimpleService.ISimpleService" behaviorConfiguration="web">
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
....
....
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
Everything else works fine, I can make SOAP and RESTful calls w/o issue via https. But WSDL always returns blank (bad request). HTTP returns WSDL fine.
Trace log inner exception reports:
The body of the message cannot be read because it is empty.
serviceMetaData tag is set:
<serviceMetadata
httpGetEnabled="true"
policyVersion="Policy15"
httpsGetEnabled="true" />
web.Config sections
Binding:
<bindings>
<basicHttpBinding>
<binding name="soapBinding">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
You will immediately notice security mode="None"
Via ServiceHostFactory I see the mode to transport as:
ServiceHost serviceHost = new ServiceHost(service.GetType(), baseAddresses);
if (ExposeSSL(baseAddresses[0]))
{
foreach (var endpoint in serviceHost.Description.Endpoints)
{
if (endpoint.Binding is WebHttpBinding)
{
((WebHttpBinding)endpoint.Binding).Security.Mode = WebHttpSecurityMode.Transport;
endpoint.Address = new EndpointAddress(baseAddresses[0].ToString().Replace("http", "https"));
}
if (endpoint.Binding is BasicHttpBinding)
{
((BasicHttpBinding)endpoint.Binding).Security.Mode = BasicHttpSecurityMode.Transport;
endpoint.Address = new EndpointAddress(baseAddresses[0].ToString().Replace("http", "https"));
}
}
Services configuration:
<service name="xxxx.Wcf.AdminJsonService" behaviorConfiguration="DefaultBehaviour">
<host>
<baseAddresses>
<!-- note, choose an available port-->
<add baseAddress="http://localhost:62701/json"/>
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="jsonBehavior" bindingNamespace="https://www.xxxx/WebService4/AdminJsonService" contract="xxxx.Wcf.IAdminJsonService"/>
</service>
<service name="xxxx.Wcf.AdminXmlService" behaviorConfiguration="DefaultBehaviour">
<host>
<baseAddresses>
<!-- note, choose an available port-->
<add baseAddress="http://localhost:62701/xml"/>
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="poxBehavior" bindingNamespace="https://www.xxx/WebService4/AdminXmlService" contract="xxxx.Wcf.IAdminXmlService"/>
</service>
<service name="xxxx.Wcf.AdminSoapService" behaviorConfiguration="DefaultBehaviour">
<!-- Service Endpoints -->
<endpoint binding="basicHttpBinding" behaviorConfiguration="soapBehavior" bindingNamespace="https://www.example.com/WebService4/AdminSoapService" contract="xxxx.Wcf.IAdminSoapService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
Endpoint behaviours
<!-- SOAP -->
<behavior name="soapBehavior">
</behavior>
<!-- JSON -->
<behavior name="jsonBehavior">
<webHttp/>
</behavior>
<!-- POX -->
<behavior name="poxBehavior">
<webHttp/>
</behavior>
Service Behaviours
<behavior name="ErrorBehaviour">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="DefaultBehaviour">
<NiceErrorHandler/>
<!-- 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"/>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata
httpGetEnabled="true"
policyVersion="Policy15"
httpsGetEnabled="true" />
</behavior>
Also have
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
Anyone have idea's why this may be occurring?
Did you try turning off one of the other endpoints? In my case WCF didn't work until I disabled one of the endpoints. It didn't matter which one I disabled. The others would work.
<services>
<service name="GTW.TrendToolService" behaviorConfiguration="MyServiceBehavior">
<!--<endpoint name="rest" address="" binding="webHttpBinding" contract="TT.ITrendtoolService" behaviorConfiguration="restBehavior"/>-->
<endpoint name="json" address="json" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="GTW.IAqvService" />
<endpoint name="xml" address="xml" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="GTW.IAqvService" />
<!--<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="GTW.IAqvService" />
<endpoint name="soap" address="soap" binding="basicHttpBinding" contract="GTW.IAqvService" />-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp />
</behavior>
<behavior name="jsonBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
I believe your issue is going to be related to your service behaviors section. Specifically you told .net to publish your WSDL in HTTP but not HTTPS. Try the following
<behavior name="DefaultBehaviour">
<NiceErrorHandler/>
<!-- 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"/>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata
httpGetEnabled="true"
httpsGetEnabled="true"
policyVersion="Policy15"
httpsGetEnabled="true" />
</behavior>
Note the extra line in the serviceMetadata referring to httpsGet as opposed to http.
I will assume that https is enabled on both the bindings and in your application given that you can see the http WSDL rather than some mumble jumbo about not being able to find bindings or something...
When you are doing the Transport encryption you have to add the s to your base address protocol ex: < add baseAddress="https://localhost:62701/xml"/> or < add baseAddress="http://localhost:62701/json"/>