2017-01-20 2 views
0

У меня проблема с HTTPClient в Appcelerator Titanium. Я использую его для запроса GET по следующему конечной точке:Titanium HTTPClient не возвращает полный ответ

https://rxnav.nlm.nih.gov/REST/interaction/list.json?rxcuis=5640+53694 

Он должен возвращать ответ, как это:

{ 
    "nlmDisclaimer":"It is not the intention of NLM to provide specific medical advice, but rather to provide users with information to better understand their health and their medications. NLM urges you to consult with a qualified physician for advice about medications.", 
    "userInput":{ 
     "sources":[ 
     "" 
     ], 
     "rxcuis":[ 
     "5640", 
     "53694" 
     ] 
    }, 
    "fullInteractionTypeGroup":[ 
     { 
     "sourceDisclaimer":"DrugBank is intended for educational and scientific research purposes only and you expressly acknowledge and agree that use of DrugBank is at your sole risk. The accuracy of DrugBank information is not guaranteed and reliance on DrugBank shall be at your sole risk. DrugBank is not intended as a substitute for professional medical advice, diagnosis or treatment..[www.drugbank.ca]", 
     "sourceName":"DrugBank", 
     "fullInteractionType":[ 
      { 
       "comment":"Drug1 (rxcui = 53694, name = nimesulide, tty = IN). Drug2 (rxcui = 5640, name = Ibuprofen, tty = IN). Drug1 is resolved to nimesulide, Drug2 is resolved to Ibuprofen and interaction asserted in DrugBank between Nimesulide and Ibuprofen.", 
       "minConcept":[ 
        { 
        "rxcui":"53694", 
        "name":"nimesulide", 
        "tty":"IN" 
        }, 
        { 
        "rxcui":"5640", 
        "name":"Ibuprofen", 
        "tty":"IN" 
        } 
       ], 
       "interactionPair":[ 
        { 
        "interactionConcept":[ 
         { 
          "minConceptItem":{ 
           "rxcui":"53694", 
           "name":"nimesulide", 
           "tty":"IN" 
          }, 
          "sourceConceptItem":{ 
           "id":"DB04743", 
           "name":"Nimesulide", 
           "url":"http://www.drugbank.ca/drugs/DB04743#interactions" 
          } 
         }, 
         { 
          "minConceptItem":{ 
           "rxcui":"5640", 
           "name":"Ibuprofen", 
           "tty":"IN" 
          }, 
          "sourceConceptItem":{ 
           "id":"DB01050", 
           "name":"Ibuprofen", 
           "url":"http://www.drugbank.ca/drugs/DB01050#interactions" 
          } 
         } 
        ], 
        "severity":"N/A", 
        "description":"The risk or severity of adverse effects can be increased when Ibuprofen is combined with Nimesulide." 
        } 
       ] 
      } 
     ] 
     } 
    ] 
} 

Вместо с титаном HTTPClient я получаю только это в ответ:

{ 
    "nlmDisclaimer":"It is not the intention of NLM to provide specific medical advice, but rather to provide users with information to better understand their health and their medications. NLM urges you to consult with a qualified physician for advice about medications.", 
    "userInput":{ 
     "sources":[ 
     "" 
     ], 
     "rxcuis":[ 
     "5640+53694" 
     ] 
    } 
} 

код для выполнения запроса является следующее:

var client = Ti.Network.createHTTPClient({ 

     onload: function() { 
      console.log(this.responseText); 
      var json = JSON.parse(this.responseText); 
      console.log(json); 
     }, 

     onerror: function() { 
      console.log(this.responseText); 
     } 

    }); 

    var url = "https://rxnav.nlm.nih.gov/REST/interaction/list.json?rxcuis=5640+53694"; 
    client.open("GET", url); 
    client.setRequestHeader("Accept", "application/json"); 
    client.send(); 

Я также попытался вернуть xml вместо json, но это то же самое, возвращается только первая часть ответа. Любая подсказка о том, как это исправить?

ответ

0

Я просто побежал ваш код и, кажется, работает хорошо для меня:

[INFO] {"nlmDisclaimer":"It is not the intention of NLM to provide specific medical advice, but rather to provide users with information to better understand their health and their medications. NLM urges you to consult with a qualified physician for advice about medications.","userInput":{"sources":[""],"rxcuis":["5640","53694"]},"fullInteractionTypeGroup":[{"sourceDisclaimer":"DrugBank is intended for educational and scientific research purposes only and you expressly acknowledge and agree that use of DrugBank is at your sole risk. The accuracy of DrugBank information is not guaranteed and reliance on DrugBank shall be at your sole risk. DrugBank is not intended as a substitute for professional medical advice, diagnosis or treatment..[www.drugbank.ca]","sourceName":"DrugBank","fullInteractionType":[{"comment":"Drug1 (rxcui = 53694, name = nimesulide, tty = IN). Drug2 (rxcui = 5640, name = Ibuprofen, tty = IN). Drug1 is resolved to nimesulide, Drug2 is resolved to Ibuprofen and interaction asserted in DrugBank between Nimesulide and Ibuprofen.","minConcept":[{"rxcui":"53694","name":"nimesulide","tty":"IN"},{"rxcui":"5640","name":"Ibuprofen","tty":"IN"}],"interactionPair":[{"interactionConcept":[{"minConceptItem":{"rxcui":"53694","name":"nimesulide","tty":"IN"},"sourceConceptItem":{"id":"DB04743","name":"Nimesulide","url":"http://www.drugbank.ca/drugs/DB04743#interactions"}},{"minConceptItem":{"rxcui":"5640","name":"Ibuprofen","tty":"IN"},"sourceConceptItem":{"id":"DB01050","name":"Ibuprofen","url":"http://www.drugbank.ca/drugs/DB01050#interactions"}}],"severity":"N/A","description":"The risk or severity of adverse effects can be increased when Ibuprofen is combined with Nimesulide."}]}]}]} 

Использование Ti SDK 6.0.1.GA в приложение IOS.

Имейте в виду, что если вы используете это на Android, возможно, что logcat разрезает журналы, так как существует ограничение символов. Возможно, вам захочется попытаться распечатать console.log(json.fullInteractionTypeGroup), чтобы убедиться, что вы получаете этот ключ обратно.

Если это не работает, обновить свой вопрос с вами версию SDK, версия Alloy, цель проекта и т.д.

+0

Я использую 5.2.0, может быть проблема? И да, я пытался записать все из json. На данный момент я решил использовать другой пользовательский веб-сервис, который вернет полный ответ титановому клиенту. – revy

+0

Тогда, может быть, это что-то с веб-службой. Можете ли вы попробовать либо SDK 6.0.1, либо запустить приложение на iOS? –

Смежные вопросы