Web service test page uses internal port

B

Ben M

I am having trouble with the ASP.NET web service auto-generated test page
which is created automatically when a web service is defined. It adds our
internal port number in the form submit location which breaks the page since
our external port number is much different. Is there any way to set that
port number manually or stop it from using the internal port?

I will describe our situation in more detail below if what I said above does
not make sense.

Requests come into our load balancer on port 80 or port 443 (the load
balancer is also an ssl off-loader which deals with the ssl certificates and
client connections). It then connects to one of our 8 web servers using an
internal ip address and port number (such as 8000 in this case). It always
communicates with the web server unsecured.

Our web services work, but the auto-generated test page does not because it
adds in the internal port number for some reason. I need to get rid of that
port number so that remote developers can use the test page.
 
S

Steven Cheng[MSFT]

Hi Ben,

From your description, I got that you have an ASP.NET webservice which has
been hosted behind some load-balance server. And you find that the default
test page(use http post) doesn't quite work as the postback url is pointing
to the internal url(not the load balance one), correct?

Based on my experience, this is due to the limitation of http/get test
page's generation. ASP.NET webservice by default use the url (from local
server view) for the service address of all those binding ports(soap,
soap12 , HTTP GET or HTTP POST). For SOAP ones, we can perform some
customization through the means mentioned below:

#Walkthrough: Customizing the Generation of Service Descriptions and Proxy
Classes
http://msdn2.microsoft.com/en-us/library/x4s9z3yc.aspx

#Modifying WSDL in Visual Studio 2003
http://forums.asp.net/p/951337/1586924.aspx#1586924

However, http get/post endpoints doesn't expose the interfaces for us to
customize it. For the test page, it use "HTTP/POST" approach, therefore, if
you do need a test page that use the external(load-balance awared) url, you
can create a custom test page which simply contains the html <form> that
point to the correct address. And for other parts on the form, you can
simply dupliate them from the default test page. BTW, the following
article mentioned the way to modify(or provide a custom version of the
"DefaultWsdlHelpGenerator.aspx", you can also have a look for reference
though that's not quite recommended:

#How-to: Customize the Generated Web Service Test Page
http://weblogs.asp.net/jan/archive/2004/01/29/64291.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
 
B

Ben M

Thank you Steven! Using the links you provided I was able to fix most, but
not all, of my problems. Now that I understand the situation better I have
identified 3 issues, two of which I have resolved (documented below for
reference) and one that has not been resolved which I still need your help
with.

#1 - Port in test page
-------------------------------
I was able to fix this issue by copying the DefaultWsdlHelpGenerator.aspx
file from the current framework config sub directory to my website and adding
1 line of code to remove the port from the test page when it was posted to
our live server. I left it alone if the location was localhost so that I
could still develop using custom port numbers. Here is the line of code I
added:

if (!httpAddress.Location.StartsWith("http://localhost"))
{httpAddress.Location = httpAddress.Location.Replace("8000",
"80").ToString();}

I also had to add the following to the web config file in order to use the
custom test page:

<webServices>
<wsdlHelpGenerator href="DefaultWsdlHelpGenerator.aspx"/>
</webServices>

#2 - Port in the WSDL for Soap
---------------------------------------------
I was able to fix this by adding a custom class to the App_Code directory:

Imports System
Imports System.Web.Services.Description

Public Class CustomSoapExtensionReflector
Inherits SoapExtensionReflector

Public Overloads Overrides Sub ReflectMethod()
'no-op
End Sub

Public Overloads Overrides Sub ReflectDescription()
Dim description As ServiceDescription =
ReflectionContext.ServiceDescription
For Each service As Service In description.Services
For Each port As Port In service.Ports
For Each extension As ServiceDescriptionFormatExtension In
port.Extensions
Dim binding As SoapAddressBinding = TryCast(extension,
SoapAddressBinding)
If binding IsNot Nothing Then
If Not
binding.Location.StartsWith("http://localhost") Then
binding.Location =
binding.Location.Replace(":8000", "")
End If
End If
Next
Next
Next
End Sub
End Class

And also modifying the web.config to point to the new class:

<webServices>
<soapExtensionReflectorTypes>
<add type="CustomSoapExtensionReflector, App_Code"/>
</soapExtensionReflectorTypes>
</webServices>

#2 - Port in the WSDL for Http
--------------------------------------------
This issue has NOT been resolved. Although the solution to issue #2 solved
the first two items in the WSDL (see Soap & Soap12 below) it did not solve
the third item, HttpPost (see the port 8000 still in the WSDL file below). I
still need help figuring out how to change that one along with the others.

<wsdl:service name="MyWebServices">
<wsdl:port name="MyWebServicesSoap" binding="tns:MyWebServicesSoap">
<soap:address location="http://www.mydomain.com/MyWebServices.asmx" />
</wsdl:port>
<wsdl:port name="MyWebServicesSoap12" binding="tns:MyWebServicesSoap12">
<soap12:address location="http://www.mydomain.com/MyWebServices.asmx" />
</wsdl:port>
<wsdl:port name="MyWebServicesHttpPost" binding="tns:MyWebServicesHttpPost">
<http:address location="http://www.mydomain.com:8000/MyWebServices.asmx"
/>
</wsdl:port>
</wsdl:service>

Thanks in advance for any additional help!
 
S

Steven Cheng[MSFT]

Thanks for your reply Ben,

Yes, the 3rd question is also what I have mentioned in last reply.
Currently it seems ASP.NET webservice handler has done the http GET/POST
test page rendering itself and doesn't provide any means to customize it.
I've met some one encountering the same problem before. So far what we can
get is using a custom test page to invoke the webservice via http GET/POST.
You will also need to replace the test page link in the WSDL document
display page.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.





-------------------->
 
S

Steven Cheng[MSFT]

Hi Ben,

Any progress on this? If there is anything else we can help, please feel
free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.






--------------------
From: (e-mail address removed) (Steven Cheng[MSFT])
Organization: Microsoft
Date: Tue, 13 Nov 2007 02:55:57 GMT
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top