我使用了来自http://www.ncbi.nlm.nih.gov/books/NBK55696/的示例代码“Using WebEnv& QueryKey example” - 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文件(只有二进制文件),因为除了ELink示例之外,http://www.ncbi.nlm.nih.gov/books/NBK55696/上的所有其他exapmles都可以正常工作:
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项目中。
他们的自述文件说应该使用JDK版本7.0.45和Axis2版本1.6.2并且它于2013年12月发布。
我在Google中搜索“下载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
我在Google上搜索了类似的案例,但我找不到解决方案。如何修复开头提到的这条消息?
答案 0 :(得分:0)
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导入和使用这些文件(指向教程中的文件名)。
对我来说很好。希望有所帮助。