jQuery soap客户端不起作用,但JavaScript客户端确实有效

时间:2015-04-24 12:17:54

标签: javascript jquery web-services soap

我有一个JavaScript soap客户端,但我需要将它移植到jQuery。 我遇到问题,我认为问题是jquery客户端没有正确发送参数。

我将两个客户留在下面。

function getResQuery(selectedResource)
{
  $.ajax(
  {
    type: 'POST',
    url:  'http://localhost:8080/OntoSakaiWS/services/WSInterface?wdsl',
    headers: {
        SOAPAction: 'getToolElementsBelongToResources'
    },
    contentType: 'text/xml; charset=utf-8',
    dataType: 'xml',
    data: '<?xml version="1.0" encoding="utf-8" ?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getToolElementsBelongToResources xmlns="http://localhost:8080/OntoSakaiWS/services/WSInterface/"><resource>'+selectedResource+'</resource></getToolElementsBelongToResources></soap:Body></soap:Envelope>',
    success: function(xmlDoc) {
       alert(xmlDoc);

    },
    error: function() {
        alert("Error")    }
  });
}

 var objXMLHttpRequest = new XMLHttpRequest();
function getToolElementsBelongToResource(subject){      
      _subject=subject;
      var xmlDoc=null;           
      selectedResource=document.getElementById('asignaturas');
      selectedResource=subject;
      selectedResource+="_Resources";
      var downloadMasterLink="http://localhost:8080/OntoFiles/"+subject;
      var resourceList=new Array();
      objXMLHttpRequest = new XMLHttpRequest();
      objXMLHttpRequest.open("POST", "http://localhost:8080/OntoSakaiWS/services/WSInterface?wdsl", true);      
      objXMLHttpRequest.onreadystatechange = function () {       
        if (objXMLHttpRequest.readyState == 4 && objXMLHttpRequest.status == 200) {
            result = objXMLHttpRequest.responseXML;           
            xmlDoc=objXMLHttpRequest.responseXML
            if (xmlDoc != null){   

          }         
        }

      }
    }    
      objXMLHttpRequest.open("POST", "http://localhost:8080/OntoSakaiWS/services/WSInterface?wdsl", true);      
      objXMLHttpRequest.setRequestHeader("SOAPAction", "getToolElementsBelongToResources");
      objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
      var packet = '<?xml version="1.0" encoding="utf-8" ?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getToolElementsBelongToResources xmlns="http://localhost:8080/OntoSakaiWS/services/WSInterface/"><resource>'+selectedResource+'</resource></getToolElementsBelongToResources></soap:Body></soap:Envelope>';
      objXMLHttpRequest.send(packet);  
}

对我来说没有意义。 jquery有什么错误?

编辑:这些是服务器响应。第一个来自jquery函数。

<soapenv:Envelope xmlns:soapenv=​"http:​/​/​schemas.xmlsoap.org/​soap/​envelope/​" xmlns:xsd=​"http:​/​/​www.w3.org/​2001/​XMLSchema" xmlns:xsi=​"http:​/​/​www.w3.org/​2001/​XMLSchema-instance">​
    <soapenv:Body>
        ​<getToolElementsBelongToResourcesResponse xmlns=​"http:​/​/​localhost:​8080/​OntoSakaiWS/​services/​WSInterface/​">
        ​<ns1:getToolElementsBelongToResourcesReturn xmlns:ns1=​"http:​/​/​OntoSakai" xsi:nil=​"true">​</ns1:getToolElementsBelongToResourcesReturn>
        ​</getToolElementsBelongToResourcesResponse>
    ​</soapenv:Body>
​</soapenv:Envelope>​


<soapenv:Envelope xmlns:soapenv=​"http:​/​/​schemas.xmlsoap.org/​soap/​envelope/​" xmlns:xsd=​"http:​/​/​www.w3.org/​2001/​XMLSchema" xmlns:xsi=​"http:​/​/​www.w3.org/​2001/​XMLSchema-instance">​
    <soapenv:Body>
        ​<getToolElementsBelongToResourcesResponse xmlns=​"http:​/​/​localhost:​8080/​OntoSakaiWS/​services/​WSInterface/​">​
            <ns1:getToolElementsBelongToResourcesReturn xmlns:ns1=​"http:​/​/​OntoSakai">​( ?x = <http://localhost:8080/OntoSakaiWS/SakaiCoreOnt.owl#Tema1_DBA> )​</ns1:getToolElementsBelongToResourcesReturn>
            ​<ns2:getToolElementsBelongToResourcesReturn xmlns:ns2=​"http:​/​/​OntoSakai">​( ?x = <http://localhost:8080/OntoSakaiWS/SakaiCoreOnt.owl#Tema2_DBA> )​</ns2:getToolElementsBelongToResourcesReturn>​
            <ns3:getToolElementsBelongToResourcesReturn xmlns:ns3=​"http:​/​/​OntoSakai">​( ?x = <http://localhost:8080/OntoSakaiWS/SakaiCoreOnt.owl#Practica1_DBA> )​</ns3:getToolElementsBelongToResourcesReturn>​
            <ns4:getToolElementsBelongToResourcesReturn xmlns:ns4=​"http:​/​/​OntoSakai">​( ?x = <http://localhost:8080/OntoSakaiWS/SakaiCoreOnt.owl#Practica2_DBA> )​</ns4:getToolElementsBelongToResourcesReturn>​
            <ns5:getToolElementsBelongToResourcesReturn xmlns:ns5=​"http:​/​/​OntoSakai" xsi:nil=​"true">​</ns5:getToolElementsBelongToResourcesReturn>​</getToolElementsBelongToResourcesResponse>​
        </soapenv:Body>​
    </soapenv:Envelope>​

0 个答案:

没有答案