.Net RESTful Web服务:发送xml文件
我正在尝试将包含文件列表的xml文件发送到RESTfulWebServices。 它是vb.net中的一个项目。将数据传递到web服务的函数如下所示:.Net RESTful Web服务:发送xml文件,xml,vb.net,web-services,rest,Xml,Vb.net,Web Services,Rest,我正在尝试将包含文件列表的xml文件发送到RESTfulWebServices。 它是vb.net中的一个项目。将数据传递到web服务的函数如下所示: Private Function SendActivityToWEBSERVICE(ByVal xmlFile As String) As Boolean Try sUri = "http://localhost:35299/LiveUpdateWS/SincronizzaAttivita?d=" + xmlFile.T
Private Function SendActivityToWEBSERVICE(ByVal xmlFile As String) As Boolean
Try
sUri = "http://localhost:35299/LiveUpdateWS/SincronizzaAttivita?d=" + xmlFile.ToString()
Dim req As HttpWebRequest = WebRequest.Create(sUri.ToString())
req.Method = "GET"
req.KeepAlive = False
Dim response As HttpWebResponse = req.GetResponse()
Try
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load(response.GetResponseStream())
Catch exc As XmlException
Console.WriteLine("Eccezione " + exc.Message)
Return False
End Try
Catch ex As Exception
Console.WriteLine("Eccezione " + ex.Message)
Return False
End Try
Return True
End Function
web服务的接口如下所示:
<OperationContract>
<WebGet(UriTemplate:="SincronizzaAttivita?d={sXMLFile}")>
Function SaveDataPost(sXMLFile As String) As Boolean
如果我发送的xml文件很小,那么一切都正常。
如果我试图发送大文件,我会得到错误404.15。我看到,要向web服务发送一定大小的字符串或数据,建议使用POST而不是GET。
对我来说,始终不清楚如何修改上述代码来实现这一点
这就是我问题的解决办法。您能告诉我更改代码的内容和方法吗?您只需要使用post方法而不是GET方法 请求方法=POST 并以单独的变量而不是查询参数发送数据