---
title: "js调webservice部分代码"
author: "cookieandsession"
date: "2013-08-29T10:20:54Z"
tags: []
categories: ["行业应用"]
slug: "js-webservice"
draft: false
lastmod: "2013-08-29T10:21:51Z"
id: 1933157
url: "https://cookieandsession.iteye.com/blog/1933157"
---

```java
 var ns = "http://cn/javacoder/com/webservices/database/agent";
          	    // build SOAP request  
          	    var sr =   
          	                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +  
          	                "<soap:Envelope " +  
          	                "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +  
          	                "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +  
          	                "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +  
          	                "<soap:Body>" +  
          	                "<getRealTimeQueueDashboard  xmlns=\"" + ns + "\">" +   
          	                "</getRealTimeQueueDashboard></soap:Body></soap:Envelope>";  
          	    if (!HttpMethod) {  
          	        HttpMethod = "GET";  
          	    }  
          	    req = getXMLHttpRequest();  
          	    if (req) {  
          	        req.open(HttpMethod,url,false);
          	        var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + "getRealTimeQueueDashboard";  
          	        req.setRequestHeader("SOAPAction", soapaction); 
          	        req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");    
          	        req.send(sr); 
          	        
       	            var returnText = req.responseText;
```