- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在遵循 WSDL-first(由我们的客户提供)方法来开发 WCF 服务,但是从我的 wcf 服务生成的 WSDL 与我们的客户提供给我的 WSDL 略有不同,并且由于这种不匹配,客户在调用我的服务。
客户端提供的 wsdl:<wsdl:service name='CheckoutService'>
<wsdl:port binding='tns:CheckoutBinding' name='CheckoutServicePort'>
<soap:address location='place holder to service uri' />
</wsdl:port>
</wsdl:service>
从 wcf 服务生成的 WSDL:
<wsdl:service name="CheckoutService">
<wsdl:port binding="tns:CheckoutBinding" name="CheckoutBinging">
<soap:address location="place holder to service uri" />
</wsdl:port>
</wsdl:service>
而且,我的服务设置如下:<endpoint name="CheckoutBinding" address="" binding="basicHttpBinding" bindingName="CheckoutServicePort" bindingConfiguration="basicHttpBinding" bindingNamespace="<<namespace>>" contract="<<contractname>>" />
我已经使用 WSCF.Blue 从客户端提供的 wsdl 生成服务器 stub 代码,并对生成的代码进行了细微的更改,以发出与客户端提供的 WSDL 完全相同的 WSDL,但我不知道要在配置文件或在生成的代码中获取与客户端提供的 wsdl 文件相同的“wsdl:port/@name”。
按此 url , serviceendpoint name 属性映射到 wsdl:port/@name 和 wsdl:binding/@name。基于此,我的配置文件中的端点/@name 属性值映射到 wsdl:port/@name 和 wsdl:binding/@name 但我希望将不同的名称映射到 wsdl:port/@name 和 wsdl:binding/@name 属性。
请帮助我实现这一目标。
最佳答案
您可以尝试实现 IWsdlExportExtension 并在 ExportEndpoint 中修改 wsdl:port/@name。然后实现 IEndpointBehavior,它将您的扩展添加到端点。要使用您的新行为,您有两种选择:
using System;
using System.Configuration;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
namespace CustomWsdlExtension
{
public class PortNameWsdlBehavior : IWsdlExportExtension, IEndpointBehavior
{
public string Name { get; set; }
public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
{
}
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
{
if (!string.IsNullOrEmpty(Name))
{
context.WsdlPort.Name = Name;
}
}
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
public class PortNameWsdlBehaviorExtension : BehaviorExtensionElement
{
[ConfigurationProperty("name")]
public string Name
{
get
{
object value = this["name"];
return value != null ? value.ToString() : string.Empty;
}
set { this["name"] = value; }
}
public override Type BehaviorType
{
get { return typeof(PortNameWsdlBehavior); }
}
protected override object CreateBehavior()
{
return new PortNameWsdlBehavior { Name = Name };
}
}
}
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="portName" type="CustomWsdlExtension.PortNameWsdlBehaviorExtension, CustomWsdlExtension" />
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="customPortName">
<portName name="myCustomName" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="CustomWsdlExtension.Service">
<endpoint address="" binding="basicHttpBinding" contract="CustomWsdlExtension.IService"
behaviorConfiguration="customPortName" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<wsdl:service name="Service">
<wsdl:port name="myCustomName" binding="tns:BasicHttpBinding_IService">
<soap:address location="http://localhost:2366/Service.svc" />
</wsdl:port>
</wsdl:service>
关于wcf - WSDL 优先方法 : How to specify different names for wsdl:port and wsdl:binding?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4704148/
我正在学习网络和套接字,但有些东西我不明白。我经常听说“TCP端口”但我认为端口与应用层有关(例如 HTTP 服务器为 80)。那你为什么不说“应用程序端口”呢?为什么端口似乎与 TCP 层相关联(它
配置 Nginx 以允许像这样的 DOMAIN:PORT 请求的正确方法是什么: http://example.com:8080/?a=xxx&b=yyy&c=zzz over TCP or UDP
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
这是我的 nginx.conf,适用于 https。 如果有人输入 HTTP://dev.local.org:3002,我该如何重定向到 HTTPS://dev.local.org:3002? 这个
我在这方面需要一点帮助,而我对这方面的 RegEx 知识有点欠缺。 我有一个代理列表,我正在尝试解析该列表并将 IP 和端口号与字符串分开。 正在读取的字符串看起来像这样。(示例 1) 121.121
我正在尝试制作一个 Firefox 扩展。我需要与后台脚本 (main.js) 交换数据,所以我尝试使用端口,但它不起作用。 //Content.js self.port.on("alert",fun
我正在学习教程,他们使用命令[[ -z "$PORT" ]] && export PORT=8080我不完全明白它在做什么。我对 bash 命令的了解非常基础,所以我什至不知道用什么谷歌来解决这个问题
我已经阅读了数据表和谷歌,但我仍然不明白。 就我而言,我将 PIC18F26K20 的 PIN RC6 设置为 INPUT 模式: TRISCbits.TRISC6 = 1; 然后我用 PORT 和
我想知道是否可以将公共(public) IP 端口(例如端口 80)映射到 Azure iaas VM 上的不同本地/私有(private) IP 端口(例如端口 81)。我相信这在旧门户中是可行的,
我有一个用 python-twisted 编写的客户端,它将 UDP 数据包发送到 IP aaa.bbb.ccc.ddd 的端口 1234,然后等待响应。我还有用 C-libuv 编写的 UDP 服务
我有一个使用弹性 IP 12.34.56.78 运行的 Amazon EC2 实例。我拥有一个域名 example.com,我已将其设置为指向 EC2 实例。我在 EC2 实例的端口 80 上运行 A
我正在尝试在 AWS Lightsail 上配置网站。我做的第一件事是在 中将端口号从 22 更改为 2200 /etc/ssh/sshd_config ,然后我像这样配置了简单的防火墙 sudo u
几天前才意识到 Docker 似乎绕过了我的 iptable 规则。我对 Docker 和 iptables 的经验并不令人难以置信。最近几天尝试了很多不同的东西。还看到最近的 docker 版本有很
我从他们的website 下载了零层使用以下命令: curl -s https://install.zerotier.com | sudo bash 每当我尝试使用 zerotier cli 时,都会
我是字符串操作的新手,只是试图替换列表中的值。 我试图修复的两个输入是 MCAFEE和 PORT O'BRIAN . 所以我跑 ucwords(strtolower($rawTitle)) .但现在我
我正在使用 SSH 访问我大学的 afs 系统。我喜欢使用 rmate(远程 TextMate),它需要 SSH 隧道,因此我在 .bashrc 中包含了这个别名。 alias sshr=ssh -R
当我使用 Control-C 退出“Heroku Open”(Heroku 工具栏服务器命令)时。我无法重新启动。我收到此错误: /vendor/bundle/gems/puma-2.14.0/lib
我正在发送这样的消息: self.port.emit("nodes_grubed", textNodesValues); 并想对此使用react: worker.port.on("nodes_grub
我正在尝试在此扩展中创建一个函数,该函数将打开具有给定网址的选项卡,并在该选项卡上使用给定文件名运行脚本。该功能大部分工作正常,只是我无法在主脚本和我在新选项卡上运行的脚本之间进行通信(我为此使用了
我在我的 .NET MVC 4 元素中使用 Bootstrap ,我使用 NuGet 导入 Bootstrap 我的元素,我有一个布局页面,我在这个页面中包含 Bootstrap 标签,我的索引页面正
我是一名优秀的程序员,十分优秀!