原理是使用 SoapExtensionReflector类中的ServiceDescription,修改port name
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services.Description;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.Xml;
public class MyReflector : SoapExtensionReflector
{
public override void ReflectMethod()
{
//TODO
}
public override void ReflectDescription()
{
ServiceDescription description = ReflectionContext.ServiceDescription;
foreach (Service service in description.Services)
{
service.Ports[0].Name = "XXXPort";
foreach (Port port in service.Ports)
{
foreach (ServiceDescriptionFormatExtension extension in port.Extensions)
{
SoapAddressBinding binding = extension as SoapAddressBinding;
if (null != binding)
{
binding.Location = binding.Location.Replace("http://", "https://");
}
}
}
}
}
web.config中修改
<webServices>
<soapExtensionReflectorTypes>
<add type="MyReflector,App_code"/>
</soapExtensionReflectorTypes>
</webServices>
</system.web>
PS:MyReflector类放在App_code文件夹中,没有就新建一个。

2223

被折叠的 条评论
为什么被折叠?



