2

所以在我的公司中,我们使用 SOAP API 来连接到我们的系统,而且我对它进行了很好的排练并且可以使用所有的调用。

我只想知道如果我想构建一个可以执行 API 查询的测试登录页面,我应该从哪里开始。

如果可能的话,我更愿意使用 JavaScript,因为我们的服务器上没有安装 PHP。

寻找从哪里开始的一些方向 - 我只是从文本框中获取一个值并放置在 XML 请求中并执行它:)

任何指针表示赞赏!

4

1 回答 1

1
<script>
function fireRequest(){

            ..
            //parse your SOAP Request and set the request with 'dataContent'
            ...

            var url = //your target gateway here Java/PHP or your web service recpetor
            var postStr =//xml SOAP resquest ;
            makeRequest(url, postStr);
            }

    function getXmlHttpRequestObject() {
         if (window.XMLHttpRequest) {
            return new XMLHttpRequest(); //Mozilla, Safari ...
         } else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP"); //IE
         } else {
            alert("Your Browser does not support XMLHTTP");

         }
     }
    function makeRequest(url, param) {
    //If our readystate is either not started or finished, initiate a new request
        //clearing all divs
        receiveReq = getXmlHttpRequestObject();
        if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {

           //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
           receiveReq.open("POST", url, true);
           //Set the function that will be called when the XmlHttpRequest objects state changes
           receiveReq.onreadystatechange = responseHandler; 

           //Add HTTP headers to the request
           receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
           receiveReq.setRequestHeader("Content-length", param.length);
           receiveReq.setRequestHeader("Connection", "close");
           //Make the request
           receiveReq.send(param);
        }   
    }
    function responseHandler(){

        if (receiveReq.readyState == 4) {


            var response = receiveReq.responseText;
            if(response){
            //do what ever you want with the response XML


            }   
        }
    }
</script>

这对你的情况来说已经足够了。使用您页面上的方法。

于 2012-07-20T10:05:13.430 回答