ASP调用WEBSERVICE(转)

首先发送请求,然后处理响应。我用.net写的WebService,直接访问,点击方法名称可以看到实例代码,只需要在asp中使用Microsoft.XMLHTTP发送请求,然后处理xml的结果就行了。

要注意Namespace不能写错了。

< %@language = vbscript codepage = 936  % >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
< meta http - equiv = " Content-Type "  content = " text/html; charset=gb2312 "   />
</ head >
< body >
<
Dim  strxml 
Dim  str 

' 定义soap消息 
strxml  =   " <?xml version='1.0' encoding='utf-8'?> "  
strxml 
=  strxml  &   " <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> "  
strxml 
=  strxml  &   " <soap:Body>  "  
strxml 
=  strxml  &   " <Decrypt xmlns='http://192.168.3.239:8000/3des/'> "  
strxml 
=  strxml  &   " <strIn>4Dv5esfHAh0=</strIn> "  
strxml 
=  strxml  &   " <strKey>Not.ceNte</strKey> "  
strxml 
=  strxml  &   " </Decrypt> "  
strxml 
=  strxml  &   " </soap:Body> "  
strxml 
=  strxml  &   " </soap:Envelope> "  

Set  h  =   createobject " Microsoft.XMLHTTP "
' 向指定的URL发送Post消息 
h.open  " POST " " http://192.168.3.239:8000/3des/Service.asmx " False  
h.setRequestHeader 
" Content-Type " " text/xml; charset=utf-8 "  
h.setRequestHeader 
" Content-Length " , LEN (strxml) 
h.setRequestHeader 
" SOAPAction " " http://192.168.3.239:8000/3des/Decrypt "  
h.send (strxml) 

' 显示返回的XML信息 

If  h.Status  =   200   Then  
   
Set  xmlDOC  =  server.CreateObject( " MSXML.DOMDocument "
   xmlDOC.load(h.responseXML) 
   str 
=  xmlDOC.childNodes( 1 ).Text     ' '调用SHOWALLNODE 

    
' 遍历并取出xml中的一个节点
     Set  Node  =  xmlDOC.getElementsByTagName( " RegionID " )
    
' for x=Node.length-1 to 0 step -1
    regMgrID  =  Node.item( 0 ).Text
    
' next

   
Set  xmlDOC  =   nothing  
   response.write(str)   
Else  
   Response.Write h.Status 
& " &nbsp; "  
   Response.Write h.StatusText 
End   if  

%
>  
</ body >
</ html >  

 

转载于:https://www.cnblogs.com/ztotem/archive/2008/04/11/1148739.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值