473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HTTP 405 Error... help!

Hi all,

I'm currently trying to build a component I can use in traditional ASP
that utilizes the .NET webservice. I'm using VB.NET to create my class,
and I am registering the class for COM Interop when I compile. I'm
encountering some problems with testing using the class in a VB.NET
console application. I keep getting a http 405 error (I've never seen
this kind of error before).

In Visual Studio, I get this error:

An unhandled exception of type 'System.Net.WebException' occurred in
system.web.services.dll

Additional information: The request failed with HTTP status 405: Method
Not Allowed.

Here is the source code for the class I'm using:
Expand|Select|Wrap|Line Numbers
  1. Public Class Proximity
  2.  
  3. Private _strPublicStagingURL As String
  4. Private _strPublicProductionURL As String
  5. Private _strSecureStagingURL As String
  6. Private _strSecureProductionURL As String
  7. Private _strStreet As String
  8. Private _strCity As String
  9. Private _strState As String
  10. Private _strZip As String
  11. Private _strCountry As String
  12. Private _dblFoundLatitude As Double
  13. Private _dblFoundLongitude As Double
  14. Private _boolFoundLocation As Boolean
  15. Private _envType As envEnvironment
  16. Private _strUsername As String
  17. Private _strPassword As String
  18. Private _strDataSourceName As String
  19. Private _intNumberFound As Integer
  20. Private _strErrorMessage As String
  21. Private _strReturnedFormattedAddress As String
  22.  
  23. Public Sub New()
  24. _strPublicStagingURL =
  25. "http://staging.mappoint.net/standard-30/mappoint.wsdl"
  26. _strPublicProductionURL =
  27. "http://service.mappoint.net/standard-30/mappoint.wsdl"
  28. _strSecureStagingURL =
  29. "https://staging.mappoint.net/secure-30/mappoint.wsdl"
  30. _strSecureProductionURL =
  31. "https://service.mappoint.net/secure-30/mappoint.wsdl"
  32. _strStreet = Nothing
  33. _strCity = Nothing
  34. _strState = Nothing
  35. _strZip = Nothing
  36. _strCountry = "US"
  37. _dblFoundLatitude = Nothing
  38. _dblFoundLongitude = Nothing
  39. _boolFoundLocation = False
  40. _envType = envEnvironment.envPublicStaging
  41. _strUsername = Nothing
  42. _strPassword = Nothing
  43. _strDataSourceName = "MapPoint.NA"
  44. _intNumberFound = Nothing
  45. _strErrorMessage = Nothing
  46. _strReturnedFormattedAddress = Nothing
  47. End Sub
  48.  
  49. Public Enum envEnvironment As Integer
  50. envPublicStaging = 1
  51. envPublicProduction = 2
  52. envSecureStaging = 3
  53. envSecureProduction = 4
  54. End Enum
  55.  
  56. Public Property Username() As String
  57. Get
  58. Return _strUsername
  59. End Get
  60. Set(ByVal Value As String)
  61. _strUsername = Value
  62. End Set
  63. End Property
  64.  
  65. Public Property Password() As String
  66. Get
  67. Return _strPassword
  68. End Get
  69. Set(ByVal Value As String)
  70. _strPassword = Value
  71. End Set
  72. End Property
  73.  
  74.  
  75. Public Property ProcessingType() As envEnvironment
  76. Get
  77. Return _envType
  78. End Get
  79. Set(ByVal Value As envEnvironment)
  80. _envType = Value
  81. End Set
  82. End Property
  83.  
  84. Public Property PublicStagingURL() As String
  85. Get
  86. Return _strPublicStagingURL
  87. End Get
  88. Set(ByVal Value As String)
  89. _strPublicStagingURL = Value
  90. End Set
  91. End Property
  92.  
  93. Public Property PublicProductionURL() As String
  94. Get
  95. Return _strPublicProductionURL
  96. End Get
  97. Set(ByVal Value As String)
  98. _strPublicProductionURL = Value
  99. End Set
  100. End Property
  101.  
  102. Public Property SecureProductionURL() As String
  103. Get
  104. Return _strSecureProductionURL
  105. End Get
  106. Set(ByVal Value As String)
  107. _strSecureProductionURL = Value
  108. End Set
  109. End Property
  110.  
  111. Public Property SecureStagingURL() As String
  112. Get
  113. Return _strSecureStagingURL
  114. End Get
  115. Set(ByVal Value As String)
  116. _strSecureStagingURL = Value
  117. End Set
  118. End Property
  119.  
  120. Public Property Street() As String
  121. Get
  122. Return _strStreet
  123. End Get
  124. Set(ByVal Value As String)
  125. _strStreet = Value
  126. End Set
  127. End Property
  128.  
  129. Public Property City() As String
  130. Get
  131. Return _strCity
  132. End Get
  133. Set(ByVal Value As String)
  134. _strCity = Value
  135. End Set
  136. End Property
  137.  
  138. Public Property State() As String
  139. Get
  140. Return _strState
  141. End Get
  142. Set(ByVal Value As String)
  143. _strState = Value
  144. End Set
  145. End Property
  146.  
  147. Public Property Zip() As String
  148. Get
  149. Return _strZip
  150. End Get
  151. Set(ByVal Value As String)
  152. _strZip = Value
  153. End Set
  154. End Property
  155.  
  156. Public Property Country() As String
  157. Get
  158. Return _strCity
  159. End Get
  160. Set(ByVal Value As String)
  161. _strCity = Value
  162. End Set
  163. End Property
  164.  
  165. Public ReadOnly Property LastError() As String
  166. Get
  167. Return _strErrorMessage
  168. End Get
  169. End Property
  170.  
  171. Public ReadOnly Property HasError() As Boolean
  172. Get
  173. Return _strErrorMessage = ""
  174. End Get
  175. End Property
  176.  
  177. Public ReadOnly Property ReturnedAddress() As String
  178. Get
  179. Return _strReturnedFormattedAddress
  180. End Get
  181. End Property
  182.  
  183. Public ReadOnly Property FoundLocation() As Boolean
  184. Get
  185. Return _boolFoundLocation
  186. End Get
  187. End Property
  188.  
  189. Public ReadOnly Property FoundLatitude() As Double
  190. Get
  191. Return _dblFoundLatitude
  192. End Get
  193. End Property
  194.  
  195. Public ReadOnly Property FoundLongitude() As Double
  196. Get
  197. Return _dblFoundLongitude
  198. End Get
  199. End Property
  200.  
  201. Public Sub FindAddress()
  202.  
  203. 'Set up the Address object and the FindAddressSpecification
  204. object
  205. Dim findService As New MapPoint.FindServiceSoap
  206. Dim myAddress As New MapPoint.Address
  207. Dim sstrURL As String
  208. Dim foundAddressResults As MapPoint.FindResults
  209. Dim findAddressSpec As New MapPoint.FindAddressSpecification
  210.  
  211. findService.Credentials = New
  212. System.Net.NetworkCredential(_strUsername, _strPassword)
  213.  
  214. Select Case _envType
  215. Case envEnvironment.envPublicStaging
  216. sstrURL = _strPublicStagingURL
  217. Case envEnvironment.envPublicProduction
  218. sstrURL = _strPublicProductionURL
  219. Case envEnvironment.envSecureProduction
  220. sstrURL = _strSecureProductionURL
  221. Case envEnvironment.envSecureStaging
  222. sstrURL = _strSecureStagingURL
  223. Case Else
  224. sstrURL =
  225. "http://staging.mappoint.net/standard-30/MapPoint.wsdl"
  226. End Select
  227.  
  228. If _strDataSourceName <> "" Then
  229. findAddressSpec.DataSourceName = _strDataSourceName
  230. Else
  231. findAddressSpec.DataSourceName = "MapPoint.NA"
  232. End If
  233.  
  234. If _strStreet <> "" Then
  235. myAddress.AddressLine = _strStreet
  236. End If
  237.  
  238. If _strCity <> "" Then
  239. myAddress.PrimaryCity = _strCity
  240. End If
  241.  
  242. If _strState <> "" Then
  243. myAddress.Subdivision = _strState
  244. End If
  245.  
  246. If _strZip <> "" Then
  247. myAddress.PostalCode = _strZip
  248. End If
  249.  
  250. If _strCountry <> "" Then
  251. myAddress.CountryRegion = _strCountry
  252. Else
  253. myAddress.CountryRegion = "US"
  254. End If
  255.  
  256. findAddressSpec.InputAddress = myAddress
  257. findService.Url = sstrURL
  258.  
  259. 'Try
  260. foundAddressResults = findService.FindAddress(findAddressSpec)
  261. _intNumberFound = foundAddressResults.NumberFound
  262.  
  263. If IsNothing(_intNumberFound) Then
  264. _boolFoundLocation = False
  265. _dblFoundLatitude = Nothing
  266. _dblFoundLongitude = Nothing
  267. _strReturnedFormattedAddress = Nothing
  268. ElseIf _intNumberFound = 0 Then
  269. _dblFoundLatitude = Nothing
  270. _dblFoundLongitude = Nothing
  271. _strReturnedFormattedAddress = Nothing
  272. _boolFoundLocation = False
  273. ElseIf _intNumberFound = 1 Then
  274. _boolFoundLocation = True
  275. _dblFoundLatitude =
  276. foundAddressResults.Results(0).FoundLocation.LatLong.Latitude
  277. _dblFoundLongitude =
  278. foundAddressResults.Results(0).FoundLocation.LatLong.Longitude
  279. _strReturnedFormattedAddress =
  280. foundAddressResults.Results(0).FoundLocation.Address.FormattedAddress
  281. Else
  282. _boolFoundLocation = False
  283. _dblFoundLatitude = Nothing
  284. _dblFoundLongitude = Nothing
  285. _strReturnedFormattedAddress = Nothing
  286. End If
  287. 'Catch ex As Exception
  288. '    _strErrorMessage = ex.GetBaseException.ToString
  289. '    _dblFoundLatitude = Nothing
  290. '    _dblFoundLongitude = Nothing
  291. '    _strReturnedFormattedAddress = Nothing
  292. 'End Try
  293.  
  294. End Sub
  295.  
  296. End Class
  297.  
  298. Here is the call I'm using in my console application to make this happen:
  299.  
  300. Sub Main()
  301. Dim objPS As New Proximity
  302. Console.WriteLine("Press ENTER to continue...")
  303. Console.ReadLine()
  304.  
  305. objPS.Username = "xxxxx"
  306. objPS.Password = "xxxxxx"
  307. objPS.ProcessingType = Proximity.envEnvironment.envPublicStaging
  308. objPS.State = "FL"
  309. objPS.City = "Miami Lakes"
  310. objPS.Zip = "33014"
  311. objPS.FindAddress()
  312.  
  313. If objPS.FoundLocation Then
  314. Console.WriteLine("Lat: " & objPS.FoundLatitude.ToString &
  315. " Long: " & objPS.FoundLongitude.ToString)
  316. Else
  317. Console.WriteLine("no geocode returned")
  318. If objPS.HasError Then
  319. Console.WriteLine(objPS.LastError)
  320. End If
  321. End If
  322.  
  323. Console.WriteLine("Press ENTER to exit...")
  324. Console.ReadLine()
  325. End Sub
  326.  
I get the error when I run the objPS.FindAddress() method. Specifically,
the error occurs when the "foundAddressResults =
findService.FindAddress(findAddressSpec)" line fires in the class.

The interesting thing is, I've had this search code work before... I
don't know what I should be looking for or doing to solve my current
problem. :(

TIA,

Cory Koski
Nov 21 '05 #1
1 8462
"Cory Koski" <co*****************@mailblocks.com> wrote in message news:eN**************@tk2msftngp13.phx.gbl...
I keep getting a http 405 error (I've never seen this kind of error before).
http://www.w3.org/Protocols/rfc2616/...html#sec10.4.6

: : An unhandled exception of type 'System.Net.WebException' occurred in
system.web.services.dll

Additional information: The request failed with HTTP status 405: Method
Not Allowed.
The "method" the error refers to is an HTTP verb (i.e., GET, POST, et al.),
the server's HttpRuntime has been configured not to answer requests with
the HTTP verb specified in your WebRequest (frequently, a GET request).

If you go into the machine.config file, by default you see a line similar to the
following under the <httpHandlers> section of <system.web>:

<add verb="*" path="*.asmx"
type="System.Web.Services.Protocols.WebServiceHand lerFactory, [...]" />

Many server administrators will restrict the verbs their .asmx's respond to:

<add verb="POST" path="*.asmx"
type="System.Web.Services.Protocols.WebServiceHand lerFactory, [...]" />

This change causes a 405 to be returned as the result code for all non-POST
HTTP requests (this reduces the risk of query string buffer overruns, exploits,
etc. on production servers, also due to URL-encoding of the query string, a
GET request isn't terribly practical for most web services, anyway).
I get the error when I run the objPS.FindAddress() method. Specifically,
the error occurs when the "foundAddressResults =
findService.FindAddress(findAddressSpec)" line fires in the class.
Assuming findService is your proxy, make sure it derives from
HttpPostClientProtocol and includes an HttpMethodAttribute on
FindAddress( ) similar to the following,

<System.Web.Services.Protocols.HttpMethodAttribute ( _
GetType( System.Web.Services.Protocols.XmlReturnReader), _
GetType( System.Web.Services.Protocols.HtmlFormParameterWri ter))>

to ensure that your HTTP method is really POST (and not GET). See
the .NET Framework documentation on both of these for all the details.
The interesting thing is, I've had this search code work before... I
don't know what I should be looking for or doing to solve my current
problem. :(


Per RFC 2616 above, the HTTP response you're receiving is supposed
to include an Allow HTTP header. This will probably tell you the server is
only accepting POST, or some limited number of verbs.
HTH,

Derek Harmon
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: qwejohn | last post by:
Hello, I had posted this question in the twisted mailing list but did not got a solution ; I hope that the python Gurus of this forum can help me a bit. I am trying the exmaple in the python...
3
by: Mark Smithers | last post by:
Hi All, I'm having a frustrating time trying to debug an ASP (not ASP.NET) app on my W2003 dev server running II6. I continually get a HTTP 500 error message despite configuring IIS 6 to...
8
by: Rene | last post by:
Hi, I'm spend many hour to fix this problem, read many articles about it but no article gave a solution. To isolate the problem I've created in IIS6 (WServer2003) a virtual directory test to...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
11
by: George | last post by:
Everytime when I redirect from one particular page to another, it will raise 4 exceptions, before Page_Load routine runs. I can't figure out a way to find out what are the exceptions. When I use...
11
by: Tomas Kepic | last post by:
Hi, i'm trying to create my first ASP.NET project ( HelloASPWorld project) but an error occured when I put OK button in NewProject. ERROR: "The Web server reported the following error when...
2
by: Paramveer | last post by:
When I am trying to create new ASP.NET application is is throwing the following error message. "The web server reported the following error when attempting to create or open the webproject...
1
by: Arfeen | last post by:
Hi All, I need help again ..... I have an asp.net web page which I hit using the "HTTP POST" method. My ASP.NET page is a basic hello world example with the following code: private void...
16
by: Harry Simpson | last post by:
I've been away from ASPNET - I open up a new Web app in VS2008 and go into properties and select to use IIS instead of the personal web server. Then I run in debug mode and it says I have to set...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.