Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Net
Imports System.IO
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Linq.JArray
Imports System.Web
' 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class HotInfoWs
Inherits System.Web.Services.WebService
Private BackendAddress As String = "http://172.17.16.55:8080"
Private contentTypeHotDeals As String = "/cms/hotDeals/index.jhtml"
Private contentTypeDealsForMembers As String = "/cms/dealsForMembers/index.jhtml"
Dim noticeInfo As String = "please check the back network!"
Dim strReturn As String = ""
Public hh As New Hashtable
Private deals = "deals"
Private members = "members"
' Public request As System.Net.HttpWebRequest
'Dim request1 As System.Web.HttpRequest
<WebMethod()> _
Public Function GetHotDeals() As String
Return getMembersServiceContent(contentTypeHotDeals, deals)
End Function
<WebMethod()> _
Public Function GetDealsForMembers() As String
Return getMembersServiceContent(contentTypeDealsForMembers, members)
End Function
Private Function getMembersServiceContent(ByVal serviceType As String, ByVal functionType As String)
Dim sm = Server.MapPath("~/") + "images\" + functionType + "\"
Try
Dim uri As New Uri(BackendAddress + serviceType)
Dim request As HttpWebRequest = WebRequest.Create(uri)
request.Method = "Get"
request.Timeout = 60000
Dim webrep As WebResponse = request.GetResponse()
Dim resStream As Stream = webrep.GetResponseStream()
Dim streamReader As New StreamReader(resStream, System.Text.Encoding.UTF8)
strReturn = streamReader.ReadToEnd()
streamReader.Close()
resStream.Close()
webrep.Close()
Catch exxx As Exception
Return noticeInfo
End Try
Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer
Dim product As New ProductInfo
' Dim products As New JavaScriptSerializer
' JsonSerializer.Deserialize(new JsonTextReader(new StringReader(sw.GetStringBuilder().ToString())), typeof(ProductCollection));
Dim dict = serializer.Deserialize(Of List(Of ProductInfo))(strReturn)
Dim productNum = dict.Count
Try
Dim ht As Hashtable = Application(functionType)
Dim list As New List(Of ProductInfo)
If ht.Keys.Count = productNum Then
Dim imgPath = ""
For Each entry As DictionaryEntry In ht
Dim pro As ProductInfo = entry.Value
imgPath = "/images/" + functionType + "/" + Split(pro.imgPath, "/")(6)
pro.imgPath = imgPath
list.Add(pro)
Next
Dim str = JavaScriptConvert.SerializeObject(list)
Return str
Else
Dim b() As Byte
' MsgBox(dict.First.title)
For Each pro As ProductInfo In dict
Dim ss = BackendAddress + pro.imgPath
Dim imageName = Split(pro.imgPath, "/")(6)
Dim dFile As New System.Net.WebClient
Dim name = sm + imageName
Try
b = dFile.DownloadData(ss)
System.IO.File.WriteAllBytes(name, b)
pro.imgPath = "images/" + functionType + "/" + imageName
' list1.Add(pro)
Catch exx As Exception
End Try
hh.Add(pro.author, pro)
Next
Application.Lock()
Application(functionType) = hh
Application.UnLock()
Dim str = JavaScriptConvert.SerializeObject(dict)
Return str
End If
' MsgBox(ht.Keys.Count)
Catch ex As Exception
Application(functionType) = hh
Dim b() As Byte
' MsgBox(dict.First.title)
For Each pro As ProductInfo In dict
Dim ss = BackendAddress + pro.imgPath
Dim imageName = Split(pro.imgPath, "/")(6)
Dim dFile As New System.Net.WebClient
Dim name = sm + imageName
Try
b = dFile.DownloadData(ss)
System.IO.File.WriteAllBytes(name, b)
pro.imgPath = "images/" + functionType + "/" + imageName
' list1.Add(pro)
Catch exx As Exception
End Try
hh.Add(pro.author, pro)
Next
Application.Lock()
Application(functionType) = hh
Application.UnLock()
Dim str = JavaScriptConvert.SerializeObject(dict)
Return str
End Try
End Function
Public Class ProductInfo
Public author As Integer
Public id As Integer
Public title As String
Public txt As String
Public imgPath As String
Public Property pauthor() As Integer
Get
Return author
End Get
Set(ByVal value As Integer)
author = value
End Set
End Property
Public Property pid() As Integer
Get
Return id
End Get
Set(ByVal value As Integer)
id = value
End Set
End Property
Public Property ptitle() As String
Get
Return title
End Get
Set(ByVal value As String)
title = value
End Set
End Property
Public Property ptxt() As String
Get
Return txt
End Get
Set(ByVal value As String)
txt = value
End Set
End Property
Public Property pimgPath() As String
Get
Return imgPath
End Get
Set(ByVal value As String)
imgPath = value
End Set
End Property
End Class
End Class
分享到:
相关推荐
网上写vb6.0调用webservice的都写得比较简单, 这个结合实例作了较详细介绍
vb6也能调用.net或Java开发的WebService,经调试可行!
描述如何在VB6里面实现webservice调用
VB.NET(2010)/JAVA 采用SOAP 与Webservice发送/接收数据
使用vb调用webservice实例,算是简单入门吧
内容概要:代码示例 C++调用WebService,Java调用WebService,C#调用WebService,Js调用WebService,VB调用WebService,ASP调用WebService,PHP调用WebService。 适用人群:WebService开发人员 使用场景:跨平台...
VB6调用webservice所需的插件 给有需要的朋友,这是我以前开发时网上下的,现在放上来和大家分享
这个小程序是和上次上传的webservice实例成对的,它用来实现对webservice服务的调用
VB 调用C# web service,同步数据
webservices VB接口 通过webservices来实现数据库同步
我们项目中的一个样例,用PB调用我们项目组的AXIS2写的WEBSERVICE。运行需要微软MSSOAP30,由于解决超时费了我很多时间,希望解决朋友们的问题。
调用https协议的webservice,以及证书手动加载。
ms soapsdk ,pb,vb,delphi可以用来调用webservice的ole 组件,适合老旧开发环境调用webservice服务。