如何将soap webservice的响应转换为visual studio 2012中的对象

时间:2016-08-25 08:32:16

标签: vb.net web-services soap xmlserializer xml-deserialization

我是webservices的新手,所以我需要知道将我从soap webservice获取的响应转换为在项目中创建的对象的最佳方法是什么。下面是我的代码正常工作并返回变量backstr中的XML数据。任何提示?提前谢谢。

    Public Function function1(ByVal claimNum As String) As String
            Try
                Dim URLReq As HttpWebRequest
                Dim URLRes As HttpWebResponse

                Dim strURL As String = "http://mywebservice?strVisaID=" & claimNum

                If Trim(strURL) <> "" Then

                    URLReq = WebRequest.Create(strURL)
                    URLRes = URLReq.GetResponse

                    Dim res As HttpWebResponse = URLReq.GetResponse()
                    Dim sr As New StreamReader(res.GetResponseStream(), System.Text.Encoding.[Default])

                    Dim backstr As String = sr.ReadToEnd()


                    If URLRes.StatusCode = HttpStatusCode.OK Then
                        Return backstr + " ok done "
                    Else
                        Return backstr + " something is wrong "
                    End If

                Else
                    Return "empty url"
                End If

            Catch ex As Exception
                Return " exception" + ex.Message
            End Try
 End Function

0 个答案:

没有答案