ASP 调用WEBservice?WDSL接口 要代码
地址如下,我想调用getcustinfo,代码如何实现http://222.240.174.179:8080/MiaWebservice/services/MiaData...
地址如下,我想调用getcustinfo,代码如何实现 http://222.240.174.179:8080/MiaWebservice/services/MiaDataService?wsdl百度复制的就不要回答了,谢谢!!
展开
展开全部
您好,1、webservice的配置文件web.config的system.web节点添加如下代码
<webServices>
<protocols>
<add
name="HttpPost"/>
<add
name="HttpGet"/>
</protocols>
</webServices>
2、asp代码
dim
url,soaprequest,retvalue
url=webservice的地址
'下面是webservice的参数
soaprequest="checkUser="
&
checkUser
&
"&checkPwd="
&
checkPwd
&
"&linkGuid="
&
linkGuid
&
"&linkPhone="
&
linkPhone
set
xmlhttp
=
server.createobject("msxml2.xmlhttp")
xmlhttp.open
"post",url,false
xmlhttp.setrequestheader
"content-type",
"application/x-www-form-urlencoded"
xmlhttp.setrequestheader
"host",host
xmlhttp.setrequestheader
"content-length",len(soaprequest)
xmlhttp.send(soaprequest)
if
xmlhttp.status
=
200
then
set
xmldoc
=
server.createobject("msxml2.domdocument")
xmldoc.load(xmlhttp.responsexml)
'xmldoc是接收了webservice返回的xml内容,如果webservice返回的不是xml,就用xmlhttp.responsetext
else
‘调用webservice失败
end
if
set
xmlhttp
=
nothing
<webServices>
<protocols>
<add
name="HttpPost"/>
<add
name="HttpGet"/>
</protocols>
</webServices>
2、asp代码
dim
url,soaprequest,retvalue
url=webservice的地址
'下面是webservice的参数
soaprequest="checkUser="
&
checkUser
&
"&checkPwd="
&
checkPwd
&
"&linkGuid="
&
linkGuid
&
"&linkPhone="
&
linkPhone
set
xmlhttp
=
server.createobject("msxml2.xmlhttp")
xmlhttp.open
"post",url,false
xmlhttp.setrequestheader
"content-type",
"application/x-www-form-urlencoded"
xmlhttp.setrequestheader
"host",host
xmlhttp.setrequestheader
"content-length",len(soaprequest)
xmlhttp.send(soaprequest)
if
xmlhttp.status
=
200
then
set
xmldoc
=
server.createobject("msxml2.domdocument")
xmldoc.load(xmlhttp.responsexml)
'xmldoc是接收了webservice返回的xml内容,如果webservice返回的不是xml,就用xmlhttp.responsetext
else
‘调用webservice失败
end
if
set
xmlhttp
=
nothing
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询