我参考的是这位大侠的代码:http://blog.csdn.net/lynnlin1122/archive/2009/02/05/3864713.aspx在做JavaScript调用webservice方面的东西,我在用MyEclipse自带的SOAP工具测试的时候得到的是这两段代码:
SOAP Request Envelope:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.xiaoair.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:example>
<q0:in0>nihao</q0:in0>
</q0:example>
</soapenv:Body>
</soapenv:Envelope>SOAP Response Envelope:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<exampleResponse xmlns:ns1="http://service.xiaoair.com">
<ns1:out>nihao</ns1:out>
</exampleResponse>
</soap:Body>
</soap:Envelope>贴上我在JavaScript里面调用的代码 <script type="text/javascript">
function CallWebService(value){
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.xiaoair.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
data = data + '<soap:Body>';
data = data + '<q0:example>';
data = data + '<q0:in0>'+value+'</q0:in0>';
data = data + '</q0:example>';
data = data + '</soap:Body>';
data = data + '</soap:Envelope>';
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL = 'http://localhost:8080/WebServiceShow/services/GISWebService?wsdl';
xmlhttp.Open("POST",URL, false);
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=gb2312");
xmlhttp.SetRequestHeader ("SOAPAction","http://service.xiaoair.com");
xmlhttp.Send(data);
document.write( xmlhttp.responseText);
alert(xmlhttp.responseText);
}
</script>看了那位大侠的文章,我也想着去拼SOAP字符串,可是不出结果,点击按钮之后整个页面的源代码就变成了wsdl文件代码那样的格式,页面本身倒是什么都没有,干干净净的。希望了解这方面知识的大侠指导小弟一下,本人不胜感激。
SOAP Request Envelope:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.xiaoair.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:example>
<q0:in0>nihao</q0:in0>
</q0:example>
</soapenv:Body>
</soapenv:Envelope>SOAP Response Envelope:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<exampleResponse xmlns:ns1="http://service.xiaoair.com">
<ns1:out>nihao</ns1:out>
</exampleResponse>
</soap:Body>
</soap:Envelope>贴上我在JavaScript里面调用的代码 <script type="text/javascript">
function CallWebService(value){
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.xiaoair.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
data = data + '<soap:Body>';
data = data + '<q0:example>';
data = data + '<q0:in0>'+value+'</q0:in0>';
data = data + '</q0:example>';
data = data + '</soap:Body>';
data = data + '</soap:Envelope>';
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL = 'http://localhost:8080/WebServiceShow/services/GISWebService?wsdl';
xmlhttp.Open("POST",URL, false);
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=gb2312");
xmlhttp.SetRequestHeader ("SOAPAction","http://service.xiaoair.com");
xmlhttp.Send(data);
document.write( xmlhttp.responseText);
alert(xmlhttp.responseText);
}
</script>看了那位大侠的文章,我也想着去拼SOAP字符串,可是不出结果,点击按钮之后整个页面的源代码就变成了wsdl文件代码那样的格式,页面本身倒是什么都没有,干干净净的。希望了解这方面知识的大侠指导小弟一下,本人不胜感激。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货