asp构造soap调用.net发布的web服务(没有代理验证)

来源:互联网 发布:晋中教育网网络教研 编辑:程序博客网 时间:2024/05/23 22:47
  1.  <%
  2. url = "http://localhost/webservice/Service.asmx"
  3. SoapRequest="<?xml version=""1.0"" encoding=""utf-8""?>"& _
  4. "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "& _
  5. "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "& _
  6. "xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""> "& _
  7. "<soap12:Header> "& _ 
  8. "</soap12:Header> "& _ 
  9. "<soap12:Body>"& _
  10. "<loginService xmlns=""http://tempuri.org/""> "& _
  11. "<SYSID>"111"</SYSID> "& _
  12. "</loginService> "& _
  13. "</soap12:Body>"& _
  14. "</soap12:Envelope>"
  15. Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
  16. xmlhttp.Open "POST",url,false
  17. xmlhttp.setRequestHeader "Content-Type""application/soap+xml; charset=utf-8"
  18. xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
  19. xmlhttp.setRequestHeader "SOAPAction""http://tempuri.org/relationService" '一定要与WEBSERVICE的命名空间相同,否则服务会拒绝
  20. xmlhttp.Send(SoapRequest)
  21. '这样就利用XMLHTTP成功发送了与SOAP示例所符的SOAP请求.
  22. '检测一下是否成功:
  23. 'Response.Write xmlhttp.Status & "<br>"
  24. Response.Write xmlhttp.responsetext
  25. Set xmlhttp = Nothing
  26. %>

原创粉丝点击