导入WebService:

时间:2010-03-19 16:53:15

标签: java web-services wsdl cxf wsdl2java

我正在尝试导入以下网络服务:http://www.biomart.org/biomart/martwsdl

使用 curl 作为服务 getResistry():一切正常:

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 ()返回列表:

Invoking getRegistry...
getRegistry.result=[]
为什么?我应该怎么做才能使这段代码有效?

非常感谢

皮尔

1 个答案:

答案 0 :(得分:0)

在客户端类中有一个main方法,您可以在其中调用getRegistry操作。

可能看起来像这样

MartServiceSoap_BioMartSoapPort_Client client = new MartServiceSoap_BioMartSoapPort_Client();
System.out.println(client.getRegistry());