doFaxSend.asp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <%
  2. url = "http://service2.winic.org:8003/Service.asmx" 'webservice 地址
  3. '==============================
  4. '通过 ADODB.Stream 流化后 用 xml 转化base64 编码 哈哈
  5. function Goodfile(filepath)
  6. Dim xmlDoc
  7. Dim xmlNode
  8. Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
  9. xmlDoc.insertBefore xmlDoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""utf-8"""), xmlDoc.childNodes(0)
  10. xmlDoc.appendChild xmlDoc.createElement("bin")
  11. Set xmlNode = xmlDoc.documentElement
  12. Dim objFile
  13. Set objFile = Server.CreateObject("ADODB.Stream")
  14. objFile.Type = 1
  15. objFile.Open
  16. objFile.LoadFromFile filepath
  17. xmlNode.dataType = "bin.base64"
  18. xmlNode.nodeTypedValue = objFile.Read(-1)
  19. objFile.Close
  20. Set objFile = Nothing
  21. Response.ContentType = "text/html"
  22. Goodfile=xmlNode.Text
  23. ' Response.ContentType = "text/xml"
  24. 'xmlDoc.Save Response
  25. Set xmlDoc = Nothing
  26. end function
  27. '=======================================
  28. '==============================发送短信函数
  29. function SendFax(uid,pwd,faxno,men,title,Bytes,FileName)
  30. SoapRequest="<?xml version="&CHR(34)&"1.0"&CHR(34)&" encoding="&CHR(34)&"utf-8"&CHR(34)&"?>"& _
  31. "<soap:Envelope xmlns:xsi="&CHR(34)&"http://www.w3.org/2001/XMLSchema-instance"&CHR(34)&" "& _
  32. "xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" "& _
  33. "xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&">"& _
  34. "<soap:Body>"& _
  35. "<SendFax xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&">"& _
  36. "<uid>"&uid&"</uid>"& _
  37. "<pwd>"&pwd&"</pwd>"& _
  38. "<faxno>"&faxno&"</faxno>"& _
  39. "<men>"&men&"</men>"& _
  40. "<title>"&title&"</title>"& _
  41. "<Bytes>"&Bytes&"</Bytes>"& _
  42. "<FileName>"&FileName&"</FileName>"& _
  43. "</SendFax>"& _
  44. "</soap:Body>"& _
  45. "</soap:Envelope>"
  46. Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
  47. xmlhttp.Open "POST",url,false
  48. xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
  49. xmlhttp.setRequestHeader "HOST","service2.winic.org"
  50. xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
  51. xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/SendFax" '一定要与WEBSERVICE的命名空间相同,否则服务会拒绝
  52. xmlhttp.Send(SoapRequest)
  53. ''样就利用XMLHTTP成功发送了与SOAP示例所符的SOAP请求.'检测一下是否返回200=成功:
  54. If xmlhttp.Status = 200 Then
  55. Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
  56. xmlDOC.load(xmlhttp.responseXML)
  57. SendFax =xmlDOC.documentElement.selectNodes("//SendFaxResult ")(0).text '显示节点为GetUserInfoResult的数据(返回字符串)
  58. Set xmlDOC = nothing
  59. Else
  60. SendFax =xmlhttp.Status&"&nbsp;"
  61. SendFax =xmlhttp.StatusText
  62. End if
  63. Set xmlhttp = Nothing
  64. end function
  65. '================================取数组中的一个
  66. function split_str(str,sint)
  67. on error resume next
  68. dim tempstr
  69. tempstr=split(str,"/") '/号分割
  70. split_str=tempstr(sint)
  71. end function
  72. '==============================
  73. dim uid,pwd,faxno,men,title,Bytes,FileName
  74. uid="your_id" '请申请的用户名
  75. pwd="your_pwd" '请申请的密码
  76. faxno=request("telNo") '接收传真电话号码
  77. faxno=replace(faxno,chr(10),",")
  78. faxno=replace(faxno,chr(13),"")
  79. faxno=replace(faxno," ","")
  80. faxno=replace(faxno,",",",")
  81. men=request.Form("txt_Fax_TO") '传真接收人
  82. title=request.Form("txt_Fax_SUB") '传真标题
  83. Bytes=Goodfile(request.Form("faxFile")) '注意: 取绝对路径哦。。如果在服务器上要先上传上去哦 再取文件路径 如"d:\xxx.doc"
  84. f_Name=split(request.Form("faxFile"),"\")
  85. FileName=f_Name(ubound(f_Name)) '只取文件名 如 "xxx.doc"
  86. response.write SendFax(uid,pwd,faxno,men,title,Bytes,FileName)
  87. %>