以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  FT 调用webservice例子  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=73839)

--  作者:kunmails
--  发布时间:2015/8/27 16:28:00
--  FT 调用webservice例子
看到论坛上有人用FT调用webservice做天气预报,但都是通过get 方式调用,有没有通过post方式调用的例子
原帖地址 http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=38007&replyID=&skin=1

--  作者:大红袍
--  发布时间:2015/8/27 16:31:00
--  

直接就行

 

Dim url As String = "http://www.foxtable.com"

Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)

Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse

Dim stm As System.IO.Stream = rsps.GetResponseStream()

Dim reader As New System.IO.StreamReader(stm)

Dim str As String = reader.ReadToEnd

rsps.Close
stm.Close
reader.close

msgbox(str)


--  作者:大红袍
--  发布时间:2015/8/27 16:41:00
--  

Post的参考

 

Dim msg As String = ""

Dim req = System.Net.WebRequest.Create("http://www.shozaioh.com/member_login?email=qlc%40qlc.jp&passwd=qianqian&cmd=login")
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = msg.Length

Dim pos = req.GetResponse

Dim stm As System.IO.Stream = pos.GetResponseStream()

Dim reader As New System.IO.StreamReader(stm)

Dim str As String = reader.ReadToEnd

pos.Close
stm.Close
reader.close

msgbox("成功")


 

 

----------------------------

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=54957&replyID=366223&skin=1

 

[此贴子已经被作者于2015/8/27 16:41:38编辑过]

--  作者:kunmails
--  发布时间:2015/8/27 17:00:00
--  

袍哥   还是不明白怎么传参数 
能否就 http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getDatabaseInfo
这个例子 写下代码

[此贴子已经被作者于2015/8/27 17:08:47编辑过]

--  作者:kunmails
--  发布时间:2015/8/27 17:16:00
--  
袍哥帮忙看下!
--  作者:大红袍
--  发布时间:2015/8/27 18:36:00
--  
看楼上啊,已经很明显了啊。换个网址就行啊
--  作者:kunmails
--  发布时间:2015/8/28 9:14:00
--  
袍哥
帮忙看下
还是不明白怎么传入参数,怎么获取返回值!
http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getDatabaseInfo
写个简单的代码参考下!

--  作者:大红袍
--  发布时间:2015/8/28 9:15:00
--  
以下是引用大红袍在2015/8/27 18:36:00的发言:
看楼上啊,已经很明显了啊。换个网址就行啊

 

+1


--  作者:大红袍
--  发布时间:2015/8/28 9:20:00
--  

Dim msg As String = ""

Dim req = System.Net.WebRequest.Create("http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getDatabaseInfo")
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = msg.Length

Dim pos = req.GetResponse

Dim stm As System.IO.Stream = pos.GetResponseStream()

Dim reader As New System.IO.StreamReader(stm)

Dim str As String = reader.ReadToEnd

pos.Close
stm.Close
reader.close

msgbox(str)


--  作者:kunmails
--  发布时间:2015/8/28 9:47:00
--  
袍哥,这个接口我用GET 方法传入参数就没有问题,但是用POST方法就出错
用post 方法该怎么传入这两个参数呢?

Dim msg As String = ""
Dim c As String = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=15091267272&userID="

Dim req = System.Net.WebRequest.Create(c)
req.Method = "GET"
req.C
req.ContentLength = msg.Length
Dim pos = req.GetResponse
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim str As String = reader.ReadToEnd
pos.Close
stm.Close
reader.close
msgbox(str)