首页 / 浏览问题 / / 问题详情
用post请求传递json参数而发布服务
7月12日, 2017
var token="TmV7n19CYk8F5RWsUb7pJF0zd-w7yQvSVe8NtUwnEK2K7C7iehJTpUZ9TwC_RA81dtIq6uJfvBa7t5JyWfvYBg..";
var url;
var requestBody;
function uploadmap(){
    var destUrl=
            "http://localhost:8090/iserver/manager/workspaces.rjson?returnContent=true&token=";
    url=destUrl+token;
    if(window.XMLHttpRequest){  
         
        xmlHttprequest=new XMLHttpRequest();  
        if(xmlHttprequest.overrideMineType){  
             
            xmlHttprequest.overrideMineTYpe("text/xml");  
        }  
    }else if(window.ActiveXObject){  
         
        var activeName=["MSXM2.XMLHTTP","Miscrosoft.XMLHTTP"];  
        for(var i=0;i<activeName.length;i++){  
            try {  
               xmlHttprequest=new ActiveXObject(activeName[i]);  
               break;  
            } catch (exception) {  
                 
            }             
        }  
    }  
 if(xmlHttprequest==undefined || xmlHttprequest==null){  
        alert("鍒涘缓xmlHttprequest澶辫触");  
         
    }else{  
        this.xmlhttp=xmlHttprequest;  
    }
    
   
    
    var method="POST";
    var async=false;
//    var requestbody = {};
//    requestbody.servicesTypes=["RESTMAP", "RESTDATA", "WMS111"];
//    requestbody.workspaceConnectionInfo="C:\Users\Administrator\Desktop\testData.smwu";
    
    var requestBody={
    
    "servicesTypes": ["RESTMAP", "RESTDATA", "WMS111"],

    "workspaceConnectionInfo": "./testDate/testData.smwu"

    };
    
    xmlHttprequest.open(method,url,async);
    
    
    xmlHttprequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    
    xmlHttprequest.send(JSON.stringify(requestBody));
    alert(JSON.stringify(requestBody));
问题关闭原因: 少打字
...