【发布时间】:2012-01-25 13:49:22
【问题描述】:
我们有一个简单的 REST 请求,我可以在我的 Mac 上手动使用 RESTClient(来自 wiztools)。网址为http://ws-argos.clsamerica.com/argosDws/services/DixService?getXml,正文如下:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:typ="http://service.dataxmldistribution.argos.cls.fr/types">
<soap:Body>
<typ:xmlRequest>
<typ:username>******</typ:username>
<typ:password>******</typ:password>
<typ:platformId>62518,62688,62520,62602,62608</typ:platformId>
<typ:nbDaysFromNow>10</typ:nbDaysFromNow>
</typ:xmlRequest>
</soap:Body>
</soap:Envelope>
这会返回带有大量真实数据的简洁 XML。所以我知道数据是可以抓取的。但是,我想在 Linux 中的夜间脚本上自动执行此操作,并尝试使用以下两个脚本使用 CURL:
curl -H "content-type: application/soap+xml" \
-H "SOAPAction:" \
-d@soap.xml \
-X POST http://ws-argos.clsamerica.com/argosDws/services/DixService?getXml \
> output.xml
调用soap.xml:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://service.dataxmldistribution.argos.cls.fr/types">
<soap:Body>
<typ:xmlRequest>
<typ:username>******</typ:username>
<typ:password>******</typ:password>
<typ:platformId>62518,62688,62520,62602,62608</typ:platformId>
<typ:nbDaysFromNow>10</typ:nbDaysFromNow>
</typ:xmlRequest>
</soap:Body>
输出是:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body><soap:Fault>
<soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code>
<soap:Reason><soap:Text xml:lang="en">Error reading XMLStreamReader.</soap:Text>
</soap:Reason>
</soap:Fault></soap:Body></soap:Envelope>
有谁知道如何解决这个问题,或者有更好的自动化方法?我是 CURL 的新手,但如果有人提出这种可能性,我可以在 Java 中创建一些东西(带有示例;-))
【问题讨论】:
标签: java web-services soap curl jax-ws