Port mapping a web service

R

Ray Johnson

I have a web service running on port 7000 on a farm of web servers.
When we expose it to the outside world, however, we port map map it to
port 80 with a BigIP. Unfortunantly, the auto-generated WSDL is
incorrect at this point.

At the bottom of the WSDL in the soap:location tag it still references
port 7000. What is weird is that has the domain name correct (i.e.
it's using the outside domain name not the internal machine name. It
just doesn't get the port correct.

Has anyone seen this before? ANyone know of a way to work around
this?

Ray
 
D

Dino Chiesa [Microsoft]

Yes:
don't use the dynamically-generated WSDL.

Generate the WSDL, then modify it to specify the proper port, then save it
or publish it or distribute it.

You may also have to tweak or disable the auto help page generator for ASMX.
 
R

Ray Johnson

Not a very good answer. Makes maintaining the WSDL a very tedious prospect.
That is a lot to give up if all you need is to expose the web service
through a port mapping web farm. Fortunantly, I found a much better answer
by calling MS support. I'll share it here since I found no help on the
internet. Hopefully, it will others who have this kind of problem.

The solution involves creating a Soap Extension Reflector. Something like
this:

public class WSDLAddress : SoapExtensionReflector
{
bool bFirstTime = true;

public override void ReflectMethod()
{

if (!bFirstTime) return;
bFirstTime = false;

SoapAddressBinding sabAddress =
ReflectionContext.Port.Extensions.Find(typeof(SoapAddressBinding)) as
SoapAddressBinding;

string sPort = ConfigurationSettings.AppSettings["myPort"];

UriBuilder uriLocation = new UriBuilder(sabAddress.Location);
uriLocation.Port = Int32.Parse(sPort);

sabAddress.Location = uriLocation.Uri.AbsoluteUri;
}
}

You also need to register the reflector in your web.config with something
like this:
<webServices>
<soapExtensionReflectorTypes>
<add type="WSDLPortMapper.WSDLAddress, PortMapperAssembly" />
</soapExtensionReflectorTypes>
</webServices>

The interesting thing to note here is that when the reflector runs you have
control over many asspects
of the WSDL generation. So this technique may be used for other tweaks on
the WSDL.

Enjoy!

Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top