【发布时间】:2015-04-17 07:42:11
【问题描述】:
这里我想使用 WCF 在我的 Restful Web 服务中将视频 url 作为参数传递。我在表格中有视频 url 列。在插入数据时,我也想插入视频网址。在网络服务中,我将视频网址作为参数发送。问题是,虽然传递参数视频 url 由“\”或“/”组成。由于这些符号,我无法通过 Web 服务插入数据。请建议我如何转义“\”或“/”符号或其他方式将视频 url 作为参数传递给 restful web 服务。
[OperationContract()]
[WebInvoke(UriTemplate = "AddPOI/{POICTG}/{Name}/{Description}/{BestTimetoVisit}/{TimeFrom}/{TimeTo}/{Address}/{Contact_No}/{Lattitude}/{Longitude}/{Altitude}/{Accuracy}/{Image}/{Video_URL}/{Active_Inactive_Flag}", Method = "GET", ResponseFormat = WebMessageFormat.Json)]
bool AddPOI(string POICTG, string Name, string Description, string BestTimetoVisit, string TimeFrom, string TimeTo, string Address, string Contact_No, string Lattitude, string Longitude, string Altitude, string Accuracy, string Image, string Video_URL, string Active_Inactive_Flag);
【问题讨论】:
-
请发布在尝试插入作为参数传递的视频 URL 时遇到的异常情况?
-
我没有得到任何异常。当我通过添加“-”来运行该 wcf 时,它正在移动到代码(通过添加断点已知)。如果我添加路径,那么它不会编码。
-
您能否发布一些关于您的 WCF 服务外观的示例代码?此外,当传递视频 URL 时,插入是否会发生在数据库中,如果是这样,那么该值如何保存为?请发布您在传递视频 URL 和不带“\”时观察到的差异
-
[OperationContract()] [WebInvoke(UriTemplate = "AddPOI/{POICTG}/{Name}/{Description}/{BestTimetoVisit}/{TimeFrom}/{TimeTo}/{Address}/{ Contact_No}/{Lattitude}/{Longitude}/{Altitude}/{Accuracy}/{Image}/{Video_URL}/{Active_Inactive_Flag}", Method = "GET", ResponseFormat = WebMessageFormat.Json)] bool AddPOI(string POICTG , string Name, string Description, string BestTimetoVisit, string TimeFrom, string TimeTo, string Address, string Contact_No, string Lattitude, string Longitude, string Altitude, string Accuracy, string Image, string Video_URL, string Active_Inactive_Flag);
-
这是我正在使用的代码,我在这里将视频 URL 作为参数传递