posts - 7, comments - 1, trackbacks - 0, articles - 0

Mozilla web service proxy~~ (for all Gecko-based browser)

Posted on 2006-07-11 12:13 Jedi 阅读(831) 评论(0)  编辑  收藏 所属分类: JavaScript
var  proxy =   null ;
  function  getTest()  // test by the way amazon uses
{
    
if (!proxy) {
        
var listener = 
        
// gets called once the proxy has been instantiated
            onLoad: function (aProxy) 
            
{
                proxy 
= aProxy;
                proxy.setListener(listener);
                requestTest();
            }
,
        
// gets called if an error occurs
            onError: function (aError) 
            
{
                alert(aError);
            }
,
        
// callback function is hardcoded to {methodname}Callback in 1.4beta
            getInstanceByIDCallback : function (aresult) 
            
{
                alert(
"enter callback");              
                
//alert("a="+aresult.a+", b="+aresult.b);
            }

        }
;
        createProxy(listener);
    }

    
else {
        requestTest(
);
    }

}

function createProxy(aCreationListener) 
{
    
try {
        
var factory = new WebServiceProxyFactory();
        factory.createProxyAsync("...wsdl location...."
, "binding name", "", true, aCreationListener);
    }

    
catch (ex) {
        alert(
"test "+ ex);
    }

}


function  requestTest() 
{
    
if (proxy) {
        netscape.security.PrivilegeManager.enablePrivilege(
"UniversalBrowserRead");
        
        
/*
        // if complex object is the parameter
        var KeywordSearchRequest = new Object();        
        KeywordSearchRequest.page="1";
        KeywordSearchRequest.mode="books";
        KeywordSearchRequest.tag="webservices-20";
        KeywordSearchRequest.type="lite";
        KeywordSearchRequest.devtag="D2Z2KU2NWTOHI";
        KeywordSearchRequest.format="xml";
        KeywordSearchRequest.version="1.0";
        
*/

        proxy.getInstanceByID(
"id.....");
        alert(
"call complete!");
    }

    
else {
        alert(
"Error: Proxy set up not complete!");
    }

}

用起来还是很简单,唯一要注意的是用Axis生成Web Service的时候记得在global configuration里面改一下
<parameter name="sendMultiRefs" value="false"/>

ie下的话也有一个webservice.htc,没仔细研究过..

只有注册用户登录后才能发表评论。


网站导航: