i created a simple webservice
Code:
<WebMethod()> _
Public Function HelloWorld(ByVal person As String) As String
Return "Hello" + person
End Function
andi created a vb.net application that i jus wanted to post the name and get back the response
Code:
' Create the web request
request = DirectCast(WebRequest.Create("http://localhost:80/WebService_RPC2"), HttpWebRequest)
' Set type to POST
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
' Create a byte array of the data we want to send
byteData = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToString())
' Set the content length in the request headers
request.ContentLength = data.Length
' Write data
Try
postStream = request.GetRequestStream()
postStream.Write(byteData, 0, byteData.Length)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
If Not postStream Is Nothing Then postStream.Close()
End Try
Try
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
' Console application output
Console.WriteLine(reader.ReadToEnd())
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
If Not response Is Nothing Then response.Close()
End Try
Dim responseString As String = Convert.ToString(reader)
but this doesn't work when i debug the code i see that the request goes through and no exception is thrown as soon as i try to read the response
Code:
response = DirectCast(request.GetResponse(), HttpWebResponse)
i get an exceptiong is thrown saying
the remote server return an error
405)Method Not allowed
can anyone tell me what i am doing wrong is there something i am not doing correcly from the webservice side?