Reputation: 6919
I have a WCF Service which I need to host on an old IIS 6 server. The server has a name Server1 but also has an alias used for the website. Apparently the server and the website resolve to different IP addresses.
So WCF Service path is
But when I look at xml generates, the schemaLocation
shows up as:
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/ProjectName" />
<xsd:import schemaLocation="https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
If I try accessing the schema specified in the xml
https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd0
I get "Page cannot be displayed" error, and if I use Network tab in Chrome debug tools, it shows the call has been aborted. But if I try accessing the schema at
https://alias.sys.domain.com/ProjectName/MyService.svc?xsd=xsd0
Then I can get to it without a problem but, unfortunately this is not the one used by the service.
To change that I added httpsGetURL in my config file:
<serviceMetadata httpGetEnabled="true" httpsGetUrl="https://alias.sys.domain.com/ProjectName/MyService.svc" />
that caused error:
A registration already exists for URI
which I was able to get rid of by adding /mex
after .svc
. The strange thing is that I do not have mex
endpoint since I cannot use it due to disabled anonymous authentication.
But adding /mex
caused another error
The message with To 'https://alias.sys.domain.com/ProjectName/MyService.svc/mex?wsdl' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
So then I added address to my endpoint, changing it from
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
to
<endpoint address="web1" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
and tried using
that changed my error to
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None) [/code]
Can anyone help?
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHTTP">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows">
</transport>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
<transport clientCredentialType="Windows">
</transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="basicBehavior" name="ProjectName.MyService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
<!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false">
</windowsAuthentication>
</serviceCredentials>-->
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/>
</system.serviceModel>
and here is the interface:
public interface IMyService
{
[OperationContract]
[WebInvoke(UriTemplate = "GetStatus/{groupID}/{groupName}", Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string GetStatus(string groupID, string groupName);
}
Upvotes: 3
Views: 5951
Reputation: 6919
Solved the issue by changing
<services>
<service behaviorConfiguration="basicBehavior" name="ProjectName.MyService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
to
<services>
<service behaviorConfiguration="basicBehavior" name="ProjectName.MyService">
<endpoint address="https://alias.sys.domain.com/ProjectName/MyService.svc" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" httpsGetUrl="https://alias.sys.domain.com/ProjectName/MyService.svc/ssl"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Upvotes: 2
Reputation: 31780
You cannot consume a RESTful service operation using WSDL. Even though metadata is exposed over the ?wsdl
query, it's not a valid definition for your service.
WSDL is only for SOAP based operations. You are exposing your operation over pure HTTP.
You should call your service using HttpClient or WebClient.
If you need to expose metadata, look at OpenAPI.
Microsoft should remove the metadata functionality for webHttpBinding because it's misleading. That they have not is a signal you should probably abandon WCF for RESTful operations and use Nancy or ASP.Net WebAPI.
Upvotes: 1