Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web Service changes port on Invoke

I have a ASP.NET Web Service on IIS, that is working on port 8080. On port 80 I have Apache, that is redirecting some web sites to IIS.

On this case, I can access the Web Service page (http://example.com/service/), which gives me all the methods available. However, when I try to invoke a method, it goes to a web page like this one: http://example.com:8080/service/Service1.asmx/Method. Of course that a public access can not see any result, the port 8080 is blocked and can not be opened.

Internally, the Web Service works on port 8080, but the public request need to be done to the port 80.

Anyone knows how can I solve my problem?

P.S.: Using IIS 7 and Apache 2.2 under Windows Server 2008

like image 890
David Campos Avatar asked Oct 27 '22 01:10

David Campos


1 Answers

The most likely reason for this is that your web service generated WSDL will define the service endpoint address as:

http://example.com:8080/service/service1.asmx

You could provide a separate static WSDL definition and modify the following section to use port 80:

<wsdl:service name="Service1"> 
    <wsdl:port name="Service1Soap" binding="tns:Service1Soap"> 
        <soap:address location="http://example.com:8080/service/service1.asmxx" /> 
    </wsdl:port> 
    <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12"> 
        <soap12:address location="http://example.com:8080/service/service1.asmx" /> 
    </wsdl:port> 
</wsdl:service>

This should cause the client to consume the WSDL and generate stub code to bind to the correct port (which is the Apache server acting as a proxy).

Another alternative method to force the correct address to appear in the generated WDSL is to use a SoapExtensionReflector to modify the address location on the fly:

Modify a Web Service's WSDL Using a SoapExtensionReflector

I have used the above method successfully in the past.

Alternatively, you could, if the client is .NET based, override the base URL for the service:

WebClientProtocol.Url Property (MSDN Library)

like image 107
Kev Avatar answered Nov 11 '22 16:11

Kev