用JavaScript调用WebService的示例

步骤如下:

下载微软HTC组件: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/behaviors/library/webservice/default.asp

Web服务WSDL:



    
        http://192.168.2.148:8080/SCRM4U_SERVICE/servlet/HLP_PWS_SYSTEM_LOGIN_SELECT.htm
        ?
    

    
        
            
                
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                

            
            
                
                    
                        
                        
                    

                

            
            
                
                    
                        
                    

                

            
        
    

    
        
    
    
        
    
    
        
            
            
        
    
    
        
        
            
            
                
            
            
                
            

        
    
    
        
            
        
    


演示代码:




...
function doService(userid, password) ...{

    //service.useService({webservice location},{webservice class name})
    service.useService("http://192.168.2.148:8080/SCRM4U_SERVICE/servlet/aws_system_login_select?wsdl","WS_SYSTEM_LOGIN_SELECT");
    //service.Service.callService({webmethod},{input parameters needed})
    service.WS_SYSTEM_LOGIN_SELECT.callService(showResult, "Execute", userid, password);
}

function showResult(result)...{

    alert(result.value.W_V_USER_MEI);
}



UserName:


PassWord:





注意:如果服务返回值类型是String,直接用result.value即可取到值。

你可能感兴趣的:(用JavaScript调用WebService的示例)