IIS中的WCF4主机,WSDL:bindingNamespace从不读取
尝试从wsdl文件中删除“tempuri”引用时出错。我已经采纳了我能想到的所有现有建议。添加IIS中的WCF4主机,WSDL:bindingNamespace从不读取,wcf,iis,wsdl,Wcf,Iis,Wsdl,尝试从wsdl文件中删除“tempuri”引用时出错。我已经采纳了我能想到的所有现有建议。添加 [ServiceBehavior(Namespace="mynamespace")] 属性添加到实现类中 [ServiceContract(Namespace="mynamespace")] 并将web.config中端点的“bindingNamespace”属性更改为匹配。然而,当加载(在IIS中)时,bindingnamespace从未更改。。永远是坦普里 有人对解决这个问题有其他想法吗?下
[ServiceBehavior(Namespace="mynamespace")]
属性添加到实现类中
[ServiceContract(Namespace="mynamespace")]
并将web.config中端点的“bindingNamespace”属性更改为匹配。然而,当加载(在IIS中)时,bindingnamespace从未更改。。永远是坦普里
有人对解决这个问题有其他想法吗?下面是web配置中的示例…无论我做什么,bindingnamespace都不会更新为mynamespace,它总是tempuri.org。如果在通过主机工厂加载端点之后,我迭代主机描述中的绑定并更新它们,那么它们将发生更改,但这似乎是一种攻击
对于以下位置的服务:http://mydomain.com/MyService.svc“以下是我的端点配置,IIS是否会使用它
<services>
<service name="ServiceImplementationClassReference,MyAssembly" >
<endpoint name=""
address="MyService.svc"
binding="basicHttpBinding"
bindingNamespace="mynamespace"
bindingConfiguration=""
contract="IMyContract" />
<endpoint name="mexHttpBinding"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
仍然引用tempuri.org的已生成WSDL文件的相关部分
<wsdl:import namespace="http://tempuri.org/" location="http://mydomain.org/MyService.svc?wsdl=wsdl0" />
<wsdl:service name="Directory">
<wsdl:port name="BasicHttpBinding_IDirectoryServices"
binding="i0:BasicHttpBinding_IDirectoryServices">
<soap:address location="http://mydomain.org/MyService.svc" />
</wsdl:port>
</wsdl:service>
在wsdl:definition节点中,xml名称空间i0(由上面列出的服务引用)也设置为tempuri.org,因此需要import语句。如果我使用BasicHttpBinding或wsHttpBinding,则temprui的使用没有变化。事实上,在web.config文件中将绑定设置为wsHttpBinding仍然会导致上面的输出,引用BasicHttpBinding_IdirectoryServices
谢谢 似乎是一个已知的问题: 这是我的web.config文件的一部分。请注意,我将我的使用限制为HTTPS,因此您可能需要执行以下操作:
<behaviors>
<endpointBehaviors>
<behavior name="Secure" />
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Company.Services.Implementation.Service" behaviorConfiguration="MetadataBehavior">
<endpoint address="" behaviorConfiguration="Secure"
binding="basicHttpBinding" bindingConfiguration="httpsBinding" bindingNamespace="http://services.company.com"
contract="Company.Services.Interfaces.IService" />
<endpoint address="mex" behaviorConfiguration="Secure"
binding="mexHttpsBinding" bindingConfiguration="httpsBinding" bindingNamespace="http://services.company.com"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="httpsBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
<mexHttpsBinding>
<binding name="httpsBinding" />
</mexHttpsBinding>
</bindings>
拉迪斯拉夫,是的,这是.NET4.0;我已经添加了wsdl文件的相关部分,希望这会有所帮助。整个事情要正确地发布还远远不够。我非常乐意将全部内容发送给任何可能觉得有用的人。谢谢我感谢你的帮助。太棒了,至少有原因!谢谢Jesse,我没有想到要看那里,我没有预料到它是架构中的一个bug。尽管我很好奇为什么节点看起来根本没有被读取。例如,我可以删除对mex端点的引用,并且只要使用空nam定义了服务行为,服务仍然可以毫无困难地提供wsdl数据。删除空名称以使其成为命名实例将禁用元数据,但将此命名实例应用为的行为配置不会起任何作用。就好像WCF 4的简化配置没有被web.config中的项目覆盖一样=/进一步研究表明这是默认情况:如何覆盖它以强制IIS使用web.config配置的端点,是在IIS之外实现自定义主机的唯一方法吗?我只是在我创建的一个服务上尝试了这个方法,但没有遇到tempuri.org问题。我有一个相当完整的web.config。请参阅我对答案的更新,以了解这是否有助于您。请注意,我使用的是WCF4,我怀疑我正在与内置的新“简化配置”默认值作斗争。我可以像您那样配置我的端点,我甚至可以在行为和绑定配置命名上犯错误,并产生错误(“不存在这样的行为”)。这告诉我配置文件正在被读取和解析。只是从来没用过。IIS似乎被锁定在使用所有默认设置:读取*.svc文件并锁定到名为“”的serviceBehavior。
/// <summary>
/// Attribute which will add a binding namespace to every endpoint it's used in.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class BindingNamespaceBehaviorAttribute : Attribute, IServiceBehavior
{
/// <summary>
/// The binding namespace;
/// </summary>
private readonly string bindingNamespace;
/// <summary>
/// Initializes a new instance of the <see cref="BindingNamespaceBehaviorAttribute"/> class.
/// </summary>
/// <param name="bindingNamespace">The binding namespace.</param>
public BindingNamespaceBehaviorAttribute(string bindingNamespace)
{
this.bindingNamespace = bindingNamespace;
}
/// <summary>
/// Gets the binding namespace.
/// </summary>
/// <value>The binding namespace.</value>
public string BindingNamespace
{
get
{
return this.bindingNamespace;
}
}
/// <summary>
/// Provides the ability to pass custom data to binding elements to support the contract implementation.
/// </summary>
/// <param name="serviceDescription">The service description of the service.</param>
/// <param name="serviceHostBase">The host of the service.</param>
/// <param name="endpoints">The service endpoints.</param>
/// <param name="bindingParameters">Custom objects to which binding elements have access.</param>
public void AddBindingParameters(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters)
{
}
/// <summary>
/// Provides the ability to change run-time property values or insert custom extension objects such as error
/// handlers, message or parameter interceptors, security extensions, and other custom extension objects.
/// </summary>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The host that is currently being built.</param>
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
}
/// <summary>
/// Provides the ability to inspect the service host and the service description to confirm that the service
/// can run successfully.
/// </summary>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The service host that is currently being constructed.</param>
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
if (serviceHostBase == null)
{
throw new ArgumentNullException("serviceHostBase");
}
foreach (var endpoint in serviceHostBase.Description.Endpoints)
{
endpoint.Binding.Namespace = this.bindingNamespace;
}
}
}
[ServiceBehavior(Namespace = "http://schemas.vevy.com/Printing")]
[BindingNamespaceBehavior("http://schemas.vevy.com/Printing")]
public class LabelsService : ILabelsService
{
// ...
}