the problem almost like this: ASP.NET Web Service changes port on Invoke.I try to use the SoapExtensionReflector to modify the service address in WSDL,and it works on SaopAddress,but the http address is still nochanging. the result like this:
- <wsdl:service name="WebService1">
- <wsdl:port name="WebService1Soap" binding="tns:WebService1Soap">
<soap:address location="http://I can remove this Port:3821/WebService1.asmx" />
</wsdl:port>
- <wsdl:port name="WebService1Soap12" binding="tns:WebService1Soap12">
<soap12:address location="http://I can remove this Port:3821/WebService1.asmx" />
</wsdl:port>
- <wsdl:port name="WebService1HttpGet" binding="tns:WebService1HttpGet">
<http:address location="http://localhost:3821/WebService1.asmx" />
</wsdl:port>
- <wsdl:port name="WebService1HttpPost" binding="tns:WebService1HttpPost">
<http:address location="http://localhost:3821/WebService1.asmx" />
</wsdl:port>
</wsdl:service>
we can see that the soap location has been changed but the last two http:address location are still Unchanged.
here is my code:
public class OuterPortReflector : SoapExtensionReflector
{
public override void ReflectMethod()
{
}
public override void ReflectDescription()
{
ServiceDescription description = ReflectionContext.ServiceDescription;
foreach (Service service in description.Services)
{
foreach (Port port in service.Ports)
{
if (!portsName.ContainsKey(port.Binding.Name))
{
portsName.Add(port.Binding.Name, true);
}
foreach (ServiceDescriptionFormatExtension extension in port.Extensions)
{
SoapAddressBinding binding = extension as SoapAddressBinding;
if (null != binding)
{
binding.Location = binding.Location.Replace("http://localhost", "http://I can remove this Port");
}
else
{
HttpAddressBinding httpBinding = extension as HttpAddressBinding;
if (httpBinding != null)
{
httpBinding.Location = httpBinding.Location.Replace("http://localhost", "http://I can remove this Port");
}
else
{
Soap12AddressBinding soap12Binding = extension as Soap12AddressBinding;
if (soap12Binding != null)
{
soap12Binding.Location = soap12Binding.Location.Replace("http://localhost", "http://I can remove this Port");
}
}
}
}
}
}
}
}
How to deal with this? Is there something wrong with my code?
hope somebady can give me some suggestion or keywords.3Q