2017-05-07 58 views
1

我想消費以下肥皂網址:請求失敗的SOAP WS返回碼404

http://89.221.253.174:8080/OpenClinica-ws/ws/data/v1/dataWsdl.wsdl

我使用谷歌通過腳本和我的代碼看起來如下:

var xml = 
      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
     +"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://openclinica.org/ws/studySubject/v1\" xmlns:bean=\"http://openclinica.org/ws/beans\">" 
     +"<soapenv:Header>" 
     +"<wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" 
     +"<wsse:UsernameToken wsu:Id=\"UsernameToken-27777511\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">" 
     +"<wsse:Username>x</wsse:Username>" 
     +"<wsse:Password>y</wsse:Password>" 
     +"</wsse:UsernameToken>" 
     +"</wsse:Security>" 
     +"</soapenv:Header>" 
     +"<soapenv:Body>" 
     +"<v1:importRequest>" 
     +"<ODM>" 
     +"<ClinicalData StudyOID=\"S_PROSPER2\" MetaDataVersionOID=\"v1.0.0\">" 
     +"<SubjectData SubjectKey=\"SS_UU001\">" 
     +"<StudyEventData StudyEventOID=\"SE_QUESW4\" StudyEventRepeatKey=\"0\">" 
     +"<FormData FormOID=\"F_RANDANDQUEST_11\">" 
     +"<ItemGroupData ItemGroupOID=\"IG_RANDA_UNGROUPED\" ItemGroupRepeatKey=\"1\" TransactionType=\"Insert\">" 
     +"<ItemData ItemOID=\"I_RANDA_RAND01\" Value=\"1\"/>" 
     +"<ItemData ItemOID=\"I_RANDA_RAND02\" Value=\"1\"/>" 
     +"<ItemData ItemOID=\"I_RANDA_RAND03\" Value=\"1\"/>" 
     +"<ItemData ItemOID=\"I_RANDA_RAND04\" Value=\"1\"/>" 
     +"</ItemGroupData>" 
     +"</FormData>" 
     +"</StudyEventData>" 
     +"</SubjectData>" 
     +"</ClinicalData>" 
     +"</ODM>" 
     +"</v1:importRequest>" 
     +"</soapenv:Body>" 
     +"</soapenv:Envelope>"; 

var options = 
     { 
     "method" : "post", 
     "contentType" : "text/xml; charset=utf-8", 
     "payload" : xml 
     }; 

    var result = UrlFetchApp.fetch("http://89.221.253.174:8080/OpenClinica-ws/ws/data/v1/dataWsdl.wsdl", options); 
    Logger.log(result); 

實際上我不知道這裏的錯誤是什麼,在這種情況下404是什麼意思?看起來像我正在與服務器通信,但其他東西丟失。

任何想法在這裏會有什麼錯?

PS:相同的代碼工作正常使用soapUI。

回答

0

解決它通過這種方式puting所有XML在一行:

var xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://openclinica.org/ws/data/v1\"><soapenv:Header><wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><wsse:UsernameToken wsu:Id=\"UsernameToken-27777511\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><wsse:Username>x</wsse:Username><wsse:Password>y</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v1:importRequest><ODM><ClinicalData StudyOID=\"S_PROSPER2\" MetaDataVersionOID=\"v1.3.0\"><SubjectData SubjectKey=\"SS_UU001\"><StudyEventData StudyEventOID=\"SE_QUESW4\" StudyEventRepeatKey=\"0\"><FormData FormOID=\"F_RANDANDQUEST_11\"><ItemGroupData ItemGroupOID=\"IG_RANDA_UNGROUPED\" ItemGroupRepeatKey=\"1\" TransactionType=\"Insert\"><ItemData ItemOID=\"I_RANDA_RAND01\" Value=\"1\"/></ItemGroupData></FormData></StudyEventData></SubjectData></ClinicalData></ODM></v1:importRequest></soapenv:Body></soapenv:Envelope>"; 

我不知道這是爲什麼它的工作方式,但它的工作!