Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 显示帖子数据!_.net_Asp.net_Vb.net_Asmx - Fatal编程技术网

.net 显示帖子数据!

.net 显示帖子数据!,.net,asp.net,vb.net,asmx,.net,Asp.net,Vb.net,Asmx,我正在尝试将vb.net应用程序中的数据发布到位于服务器上的web服务asmx 对于从vb.net应用程序发布数据,我使用以下代码: Public Function Post(ByVal url As String, ByVal data As String) As String Dim vystup As String = Nothing Try 'Our postvars Dim buffer As Byte() = Encoding.ASCI

我正在尝试将vb.net应用程序中的数据发布到位于服务器上的web服务asmx

对于从vb.net应用程序发布数据,我使用以下代码:

Public Function Post(ByVal url As String, ByVal data As String) As String
    Dim vystup As String = Nothing
    Try
        'Our postvars
        Dim buffer As Byte() = Encoding.ASCII.GetBytes(data)
        'Initialisation, we use localhost, change if appliable
        Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
        'Our method is post, otherwise the buffer (postvars) would be useless
        WebReq.Method = "POST"
        'We use form contentType, for the postvars.
        WebReq.ContentType = "application/x-www-form-urlencoded"
        'The length of the buffer (postvars) is used as contentlength.
        WebReq.ContentLength = buffer.Length
        'We open a stream for writing the postvars
        Dim PostData As Stream = WebReq.GetRequestStream()
        'Now we write, and afterwards, we close. Closing is always important!
        PostData.Write(buffer, 0, buffer.Length)
        PostData.Close()
        'Get the response handle, we have no true response yet!
        Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetResponse(), HttpWebResponse)
        'Let's show some information about the response
        Console.WriteLine(WebResp.StatusCode)
        Console.WriteLine(WebResp.Server)

        'Now, we read the response (the string), and output it.
        Dim Answer As Stream = WebResp.GetResponseStream()
        Dim _Answer As New StreamReader(Answer)

        'Congratulations, you just requested your first POST page, you
        'can now start logging into most login forms, with your application
        'Or other examples.
        vystup = _Answer.ReadToEnd()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

    Return vystup.Trim() & vbLf
End Function 

现在,我如何在asmx服务中检索此数据?

所有这些代码使您看起来像是在将数据发布到常规网页,可能是.Net Web表单,而不是Web服务。如果它是一个web服务,那么您将转而传递XML。因此,假设它是一个.NETWeb表单,您可以使用Request.Form(“无论您的变量调用什么”)访问原始POST数据。但是,看起来您没有在POST数据中传递variable=xyz,因此在web表单中您需要访问原始数据


请不要以感叹号(!)结束你的问题标题和几乎每个句子,好吗?它看起来非常吵闹,通常被认为是冒犯性的。谢谢:)你说得对!此post数据代码无法正常工作!在哪里可以找到vb.net将数据发布到asmx web服务的简单示例,以及web服务捕获发布数据的示例?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim T As String
    Using SR As New System.IO.StreamReader(Request.InputStream)
        T = SR.ReadToEnd()
    End Using
End Sub