代码之家  ›  专栏  ›  技术社区  ›  Kersten

ADBException在EFetch中使用WebEnv和QueryKey示例

  •  2
  • Kersten  · 技术社区  · 12 年前

    我使用了来自 http://www.ncbi.nlm.nih.gov/books/NBK55696/ -ESearch部分似乎工作得很好,但EFetch不行。我添加了命令“e.printStackTrace()”以获取完整的错误消息:

    WebEnv: NCID_1_160921978_130.14.18.34_9001_1392822285_1227953195  
    QueryKey: 1
    
    org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/efetch_pubmed}Affiliation  
    org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/efetch_pubmed}Affiliation  
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub.fromOM(EFetchPubmedServiceStub.java)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub.run_eFetch(EFetchPubmedServiceStub.java:190)  
    at preparation.Client.main(Client.java:39)  
    Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/efetch_pubmed}Affiliation  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$AuthorType$Factory.parse(EFetchPubmedServiceStub.java:47561)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$AuthorListType$Factory.parse(EFetchPubmedServiceStub.java:12284)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$ArticleType$Factory.parse(EFetchPubmedServiceStub.java)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$MedlineCitationType$Factory.parse(EFetchPubmedServiceStub.java:27035)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$PubmedArticleType$Factory.parse(EFetchPubmedServiceStub.java:17841)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$PubmedArticleSetChoiceE$Factory.parse(EFetchPubmedServiceStub.java)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$PubmedArticleSet_type0$Factory.parse(EFetchPubmedServiceStub.java:54143)  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$EFetchResult$Factory.parse(EFetchPubmedServiceStub.java:48494)  
    ... 3 more  
    Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/efetch_pubmed}Affiliation  
    at gov.nih.nlm.ncbi.www.soap.eutils.EFetchPubmedServiceStub$AuthorType$Factory.parse(EFetchPubmedServiceStub.java:47555)  
    ... 10 more  
    

    我将Eclipse(版本:3.7.2)与Ubuntu 12.04 LTS和java-7-openjdk-amd64作为JRE一起使用。NCBI页面提到在运行Client.java之前使用此命令:

    wsdl2java -uri http://eutils.ncbi.nlm.nih.gov/soap/v2.0/efetch_pubmed.wsdl
    

    取而代之的是,我只包含了在控制台中显示为输出的jar文件(仅二进制文件),因为这对所有其他示例都适用 http://www.ncbi.nlm.nih.gov/books/NBK55696/ 除了ELink示例:

    org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement {http://www.ncbi.nlm.nih.gov/soap/eutils/elink}error 
    

    我将描述我的项目中包含的jar文件。

    由于上述页面上用于下载eutils_axis2.jar的FTP链接不起作用,我搜索了当前路径并将其添加到Eclipse项目中。
    他们的README表示,应该使用JDK 7.0.45版和Axis2 1.6.2版,并于2013年12月发布。

    我在Google中搜索“download wsdl2java.sh”以获取与WSDL相关的Axis2版本,并找到了包Axis2-eclipse-service-plugin-1.6.2.zip。我下载了包并将所有jar文件添加到我的项目中:

    apache-mime4j-core-0.7.2.jar  
    axiom-api-1.2.13.jar  
    axiom-impl-1.2.13.jar  
    axis2-adb-1.6.2.jar  
    axis2-codegen-1.6.2.jar  
    axis2-kernel-1.6.2.jar  
    commons-codec-1.3.jar  
    commons-fileupload-1.2.jar  
    commons-httpclient-3.1.jar  
    geronimo-jta_1.1_spec-1.1.jar  
    geronimo-ws-metadata_2.0_spec-1.1.2.jar  
    jaxen-1.1.1.jar  
    jsr311-api-1.0.jar  
    neethi-3.0.2.jar  
    servlet-api-2.3.jar  
    woden-api-1.0M9.jar  
    woden-impl-commons-1.0M9.jar  
    woden-impl-dom-1.0M9.jar  
    wsdl4j-1.6.2.jar  
    XmlSchema-1.4.7.jar  
    

    然后我在包中搜索剩余的错误消息:

    axis2-transport-http-1.6.2.jar  
    axis2-transport-local-1.6.2.jar   
    commons-logging-1.1.3.jar  
    geronimo-javamail_1.4_spec-1.7.1.jar  
    httpcore-4.3.2.jar  
    

    我在谷歌上搜索了类似的案例,但没有找到解决方案。我如何修复开头提到的这条消息?

    1 回复  |  直到 12 年前
        1
  •  0
  •   Stephan    12 年前

    NCBI教程中提到的相应wsdl文件来自 2010 。也许它已经过时了,但首先,请确保创建指定的java类工作正常。以下步骤是否会导致错误?

    下载并提取 axis2-1.6.2 .

    设置环境变量

    export AXIS2_HOME=<path/to/axis2-1.6.2>
    export JAVA_HOME=<path/to/java-7-openjdk-amd64>
    

    下载以下文件

    http://eutils.ncbi.nlm.nih.gov/soap/v2.0/efetch_pubmed.xsd
    http://eutils.ncbi.nlm.nih.gov/soap/v2.0/efetch_db_pubmed.xsd
    http://eutils.ncbi.nlm.nih.gov/soap/v2.0/efetch_pubmed.wsdl
    

    并使用efetch_pubmed.wsdl文件在axis2-1.6.2目录中执行bin/wsdl2java.sh。

    sh wsdl2java.sh -uri <path/to/efetch_pubmed.wsdl>
    

    两个java类应该出现在

    src/gov/nih/nlm/ncbi/www/soap/eutils
    

    (仍在axis/bin目录中)。导入这些文件并将其与Client.java一起使用(指向教程中的文件名)。

    对我来说很好。希望这有帮助。