Exposing BizTalk interfaces as webservices is very easy using the ‘BizTalk Webservice Publishing Tool’. In almost all cases this tool generates a correct functioning web service which does not need any code modification.
However, there are situations where tweaking the code of the generated web service is necessary. Recently I needed two different BizTalk interfaces to expose the exact same WSDL. Because the two interfaces had different names for namespaces and artifacts, the generated webservices and WSDL were not the same.
You can solve this by using the SoapExtensionReflector. The BizTalk Webservice Publishing Wizard generates a class called ‘WsdlExtensions.cs’ for every webservice that is generated. By including this file in the generated VS.Net webservice project and adding the type in the 'soapExtensionReflectorTypes' section of the web.config (see header comments of
WsdlExtensions.cs), you’re able to control the generated WSDL for the webservice.
By default this file is generated with code for XML schema replacement in the WSDL, but you can use this to change other parts. For example, to override the SOAP service name, you can use:
public override void ReflectMethod()
ProtocolReflector reflector = this.ReflectionContext;
reflector.Service.Name = "MyNewServiceName";
After recompiling the web service the service name in the WSDL is changed to the new value.