【发布时间】:2016-10-10 12:30:01
【问题描述】:
我有一个 WCF 服务,我需要将它托管在旧的 IIS 6 服务器上。服务器有一个名称 Server1,但也有一个用于网站的别名。显然,服务器和网站解析为不同的 IP 地址。
所以WCF服务路径是
但是当我查看 xml 生成时,schemaLocation 显示为:
<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>
如果我尝试访问 xml 中指定的架构
https://server1.subdomain.domain.com/ProjectName/MyService.svc?xsd=xsd0
我收到“页面无法显示”错误,如果我在 Chrome 调试工具中使用“网络”选项卡,则显示调用已中止。但是,如果我尝试访问架构在
https://alias.sys.domain.com/ProjectName/MyService.svc?xsd=xsd0
然后我可以毫无问题地使用它,但不幸的是,这不是服务使用的。
要更改我在配置文件中添加的 httpsGetURL:
<serviceMetadata httpGetEnabled="true" httpsGetUrl="https://alias.sys.domain.com/ProjectName/MyService.svc" />
导致错误:
URI 的注册已经存在
我可以通过在.svc 之后添加/mex 来摆脱它。奇怪的是我没有mex 端点,因为由于禁用了匿名身份验证,我无法使用它。
但是添加/mex 导致另一个错误
带有“https://alias.sys.domain.com/ProjectName/MyService.svc/mex?wsdl”的消息 由于 EndpointDispatcher 的 AddressFilter 不匹配,无法在接收方处理。 检查发送方和接收方的 EndpointAddresses 是否一致。
然后我将地址添加到我的端点,将其更改为
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
到
<endpoint address="web1" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Projectname.IMyService"/>
并尝试使用
这将我的错误更改为
由于 ContractFilter,接收方无法处理带有 Action '' 的消息 EndpointDispatcher 不匹配。这可能是因为合同不匹配 (发送方和接收方之间的操作不匹配)或绑定/安全不匹配 发送者和接收者。检查发送方和接收方是否具有相同的合同和 相同的绑定(包括安全要求,例如消息、传输、无) [/代码]
谁能帮忙?
<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>
这是界面:
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);
}
【问题讨论】:
-
可以分享一下服务接口和配置文件(endpoint tag)吗?
-
我添加了 web.config 部分和界面。非常感谢您的帮助!