正在用WEBSERVICE作点睛文中广告,想和大家一起交流。
在IE和TT中我测试过了,都好用,现在正作Mozilla Firefox中的,可是有个地方卡住了。这是我的WEBSERVICE是。NET写的http://www.weask.cn/testMe.asmx?wsdl这是一个我测试的WEB SERVICE随便给它传一个数字,他就返回一个数字。
可以在http://www.weask.cn/testMe.asmx?op=HelloWorld这个页面中直接测试。这就是本地的HTML 和JAVASCRIPT<html>
    <head>
        <title>Mozilla Web Service Example</title>
        <script type="text/javascript">

        var sWSDL = "http://www.weask.cn/testMe.asmx?wsdl";
var sPort = "testMeSoap";
        var oProxy = null;

//the callback object for proxy creation
        var oProxyCreateCallback = {
            onLoad: function(oCreatedProxy) {
alert("create Proxy...")
                oProxy = oCreatedProxy;
alert("create Proxy success...")
                oProxy.setListener(oGetTempCallback);
            },
        
            onError: function(sError) {
                alert(sError);
            }
        
        };

//the callback object for the getTemp() method
        var oGetTempCallback = {
            testMeSoapCallback: function (iDegrees) {
alert("success") 
var result = document.getElementById("result");  
 result.innerHTML = iDegrees
             //alert("It is currently " + iDegrees + " degrees in that zip code.");
         }
        } //creates the proxy
        function createProxy() {
           try {
                var oFactory = new WebServiceProxyFactory();
                oFactory.createProxyAsync(sWSDL, sPort, "", true, oProxyCreateCallback);
            } catch (oError) {
                alert(oError.message);
            }
        }
        
//calls the web srevice
        function callWebService() {                        
            if (oProxy) {
                var sZip = document.getElementById("txtZip").value;   
alert(sZip)
                oProxy.HelloWorld(sZip);   
            } else {
                alert("Proxy not available.");
            }
                     
        }

//create the proxy when the page loads so it will be ready 
//when the button is pressed
window.onload = createProxy;

        </script>
    </head>
    <body>
    <p>This example uses the Mozilla <acronym title="Web Services Description Language">WSDL</acronym> proxy
to make an <em>asynchronous</em> call to <code>getTemp</code>.
        <p><input type="text" id="txtZip" size="10" /><input type="button" value="Get Temperature" onclick="callWebService()" />

<div id="result" ></div>
    </body>
<HTml>
那位高手能帮忙看一下,给100分。

解决方案 »

  1.   

    <html> 
            <head> 
                    <title> Mozilla   Web   Service   Example </title> 
                    <script   type="text/javascript">                 var   sWSDL   =   "http://www.weask.cn/testMe.asmx?wsdl"; 
    var   sPort   =   "testMeSoap"; 
                    var   oProxy   =   null; //the   callback   object   for   proxy   creation 
                    var   oProxyCreateCallback   =   { 
                            onLoad:   function(oCreatedProxy)   { 
    alert("create   Proxy...") 
                                    oProxy   =   oCreatedProxy; 
    alert("create   Proxy   success...") 
                                    oProxy.setListener(oGetTempCallback); 
                            }, 
                    
                            onError:   function(sError)   { 
                                    alert(sError); 
                            } 
                    
                    }; //the   callback   object   for   the   getTemp()   method 
                    var   oGetTempCallback   =   { 
                            testMeSoapCallback:   function   (iDegrees)   { 
    alert("success")   
    var   result   =   document.getElementById("result");     
      result.innerHTML   =   iDegrees 
                            //alert("It   is   currently   "   +   iDegrees   +   "   degrees   in   that   zip   code."); 
                    } 
                    } //creates   the   proxy 
                    function   createProxy()   { 
                          try   { 
                                    var   oFactory   =   new   WebServiceProxyFactory(); 
                                    oFactory.createProxyAsync(sWSDL,   sPort,   "",   true,   oProxyCreateCallback); 
                            }   catch   (oError)   { 
                                    alert(oError.message); 
                            } 
                    } 
                    
    //calls   the   web   srevice 
                    function   callWebService()   {                                                 
                            if   (oProxy)   { 
                                    var   sZip   =   document.getElementById("txtZip").value;       
    alert(sZip) 
                                    oProxy.HelloWorld(sZip);       
                            }   else   { 
                                    alert("Proxy   not   available."); 
                            } 
                                              
                    } //create   the   proxy   when   the   page   loads   so   it   will   be   ready   
    //when   the   button   is   pressed 
    window.onload   =   createProxy;                 </script> 
            </head> 
            <body> 
            <p> This   example   uses   the   Mozilla   <acronym   title="Web   Services   Description   Language"> WSDL </acronym>   proxy 
    to   make   an   <em> asynchronous </em>   call   to   <code> getTemp </code> . 
                    <p> <input   type="text"   id="txtZip"   size="10"   /> <input   type="button"   value="Get   Temperature"   onclick="callWebService()"   /> <div   id="result"   > </div> 
            </body> 
    <HTml> 
      

  2.   

    你用的方法是微软做的,其它的浏览器当然不好使,JS连webservice的方法中我现在只知道用AJAX方法直接请求webservice中的方法和微软没关系,你可以试试.就是把URL地址直接写http的地址,例URL=http://www.weask.cn/testMe.asmx/方法名