【发布时间】:2010-03-19 16:53:15
【问题描述】:
我正在尝试导入以下网络服务:http://www.biomart.org/biomart/martwsdl
对服务 getResistry() 使用 curl :一切正常:
curl --header 'Content-Type: text/xml' --data '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mar="http://www.biomart.org:80/MartServiceSoap">
<soapenv:Header/>
<soapenv:Body>
<mar:getRegistry/>
</soapenv:Body>
</soapenv:Envelope>' http://www.biomart.org:80/biomart/martsoap
它返回:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.o
rg/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<getRegistryResponse xmlns="http://www.biomart.org:80/MartServiceSoap">
<mart>
<name xsi:type="xsd:string">ensembl</name>
<displayName xsi:type="xsd:string">ENSEMBL GENES 57 (SANGER UK)</displayName>
<database xsi:type="xsd:string">ensembl_mart_57</database>
(...)
好的。
但是当使用CXF/wsdl2java(甚至是wsimport)生成这个服务时
mkdir src
wsdl2java -keep -d src -client "http://www.biomart.org/biomart/martwsdl"
javac -g -d src -sourcepath src src/org/biomart/_80/martservicesoap/MartServiceSoap_BioMartSoapPort_Client.java
java -cp src org.biomart._80.martservicesoap.MartServiceSoap_BioMartSoapPort_Client
生成的客户端为 getRegistry() 返回一个 empty 列表:
Invoking getRegistry...
getRegistry.result=[]
为什么?我应该怎么做才能使这段代码正常工作?
非常感谢
皮埃尔
【问题讨论】:
-
请出示MartServiceSoap_BioMartSoapPort_Client.java中的代码,特别是main方法,后面跟调用服务的地方。
-
@shivaspk MartServiceSoap_BioMartSoapPort_Client.java 由 CXF/wsdl2java 使用“-client”选项生成。
-
它只生成一个存根类,它所做的只是创建 WSDL 操作的 java 等价物,您需要编写一个简单的 java 程序来调用 getRegitry() 操作。
标签: java web-services wsdl cxf wsdl2java