如标题:
- C# code
<% Option Explicit Response.Buffer = true Response.ContentType = "text/html" Response.Charset = "gb2312″ Dim Url, Result Url = "http://ping.baidu.com/ping/RPC2" Result = BytesToBstr(SendPing(Url), "gb2312″) IF Instr(Result, "<int>0</int>") > 0 Then Response.Write("success") Else Response.Write("failure") End IF Function SendPing(Url) Dim s : s = "" Randomize() Dim r : r = Int(Rnd() * 9999) + 1000 s = s & "<?xml version=""1.0″" encoding=""gb2312″"?>" s = s & "<methodCall>" s = s & "<methodName>weblogUpdates.ping</methodName>" s = s & "<params>" s = s & "<param><value><string>开发网站的一些小技巧</string></value></param>" s = s & "<param><value><string>http://hi.baidu.com/subendong/blog</string></value></param>" s = s & "<param><value><string>http://hi.baidu.com/subendong/blog/item/6cd9468d243e8c07b21bba5e</string></value></param>" s = s & "<param><value><string></string></value></param>" s = s & "</params>" s = s & "</methodCall>" Response.Write "<p>发送Ping到:" & Url & "</p>" Response.Flush Dim objPing Set objPing = Server.CreateObject("MSXML2.ServerXMLHTTP") objPing.SetTimeOuts 10000, 10000, 10000, 10000 ‘第一个数值:解析DNS名字的超时时间10秒 ‘第二个数值:建立Winsock连接的超时时间10秒 ‘第三个数值:发送数据的超时时间10秒 ‘第四个数值:接收response的超时时间10秒 objPing.open "POST", Url & "?r=" & r, False objPing.setRequestHeader "Content-Type", "text/xml; charset=gb2312″ objPing.send(s) SendPing = objPing.ResponseBody Set objPing = Nothing End Function ‘=============================================== ‘函数名:BytesToBstr ‘作用:字符集转换 ‘参数:body–内容;Cset–指定的字符集 ‘=============================================== Function BytesToBstr(body, Cset) dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = Cset BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing End Function %>
------解决方案--------------------------------------------------------
asp.net c# 我看了一下。。差不多呀。。哪里提示有问题。。哪里修改呗
------解决方案--------------------------------------------------------
http://down.dvbbs.net/new_Softview/SoftView_2000.asp
http://msdn.microsoft.com/zh-cn/library/bb398858.aspx
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
上面涉及的东西也很简单,Random, HttpWebRequest, StreamReader 自己去查吧。
------解决方案--------------------------------------------------------
是不是调用web service. 如果是,如果用wsdl,直接在工程里Add web reference或者Add service Reference.
如果没有wsdl.
可以使用HttpWebRequest发送request.
参考这里的代码:
【原创】C# HttpWebRequest 发送SOAP XML
http://www.cnblogs.com/zhxhdean/archive/2012/06/12/2546277
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------