使用 marklogic 使用外部 web 服务
consuming an external web service using marklogic
遇到困难。查找有关如何使用 marklogic 访问外部 Web 服务的示例? (也许我的搜索词有误?我也尝试了 xdmp:http-get
、xdmp:http-post
、post http 请求、mash-up
、编排)。
我首先需要了解,在我继续之前,在 MarkLogic
中编写脚本来访问一个外部(非 ML)Web 服务并显示响应有多困难(希望容易)使用 ML 将来自 3 种不同 Web 服务的结果(这个混搭的正确术语是什么?)组合在一个页面中。
我们将不胜感激使用 ML 的示例。我看过 celsius 到 fahrenheit 的转换示例,还有股票报价请求和响应,但不是在 ML 中。我不知道如何或从哪里开始。你能给我指出正确的方向吗?渴望学习将 ML 用于 Web 服务。
非常感谢。
我会说这里有例子:http://docs.marklogic.com/xdmp:http-post
但为了完整起见,让我也添加这些:
Based on:
http://www.w3schools.com/xml/tempconvert.asmx?op=FahrenheitToCelsius
SOAP 1.1:
let $envelop :=
<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/">
<soap:Body>
<FahrenheitToCelsius xmlns="http://www.w3schools.com/xml/">
<Fahrenheit>100</Fahrenheit>
</FahrenheitToCelsius>
</soap:Body>
</soap:Envelope>
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx",
<options xmlns="xdmp:http">
<headers>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<SOAPAction>"http://www.w3schools.com/xml/FahrenheitToCelsius"</SOAPAction>
</headers>
</options>,
$envelop
)
SOAP 1.2:
let $envelop :=
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<FahrenheitToCelsius xmlns="http://www.w3schools.com/xml/">
<Fahrenheit>100</Fahrenheit>
</FahrenheitToCelsius>
</soap12:Body>
</soap12:Envelope>
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx",
<options xmlns="xdmp:http">
<format xmlns="xdmp:document-get">xml</format>
<headers>
<Content-Type>application/soap+xml; charset=utf-8</Content-Type>
</headers>
</options>,
$envelop
)
HTTP POST:
let $body := text {
string-join(
("Fahrenheit=" || encode-for-uri(string(100))),
"&"
)
}
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx/FahrenheitToCelsius",
<options xmlns="xdmp:http">
<headers>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
</headers>
</options>,
$body
)
HTH!
遇到困难。查找有关如何使用 marklogic 访问外部 Web 服务的示例? (也许我的搜索词有误?我也尝试了 xdmp:http-get
、xdmp:http-post
、post http 请求、mash-up
、编排)。
我首先需要了解,在我继续之前,在 MarkLogic
中编写脚本来访问一个外部(非 ML)Web 服务并显示响应有多困难(希望容易)使用 ML 将来自 3 种不同 Web 服务的结果(这个混搭的正确术语是什么?)组合在一个页面中。
我们将不胜感激使用 ML 的示例。我看过 celsius 到 fahrenheit 的转换示例,还有股票报价请求和响应,但不是在 ML 中。我不知道如何或从哪里开始。你能给我指出正确的方向吗?渴望学习将 ML 用于 Web 服务。
非常感谢。
我会说这里有例子:http://docs.marklogic.com/xdmp:http-post
但为了完整起见,让我也添加这些:
Based on: http://www.w3schools.com/xml/tempconvert.asmx?op=FahrenheitToCelsius
SOAP 1.1:
let $envelop :=
<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/">
<soap:Body>
<FahrenheitToCelsius xmlns="http://www.w3schools.com/xml/">
<Fahrenheit>100</Fahrenheit>
</FahrenheitToCelsius>
</soap:Body>
</soap:Envelope>
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx",
<options xmlns="xdmp:http">
<headers>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<SOAPAction>"http://www.w3schools.com/xml/FahrenheitToCelsius"</SOAPAction>
</headers>
</options>,
$envelop
)
SOAP 1.2:
let $envelop :=
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<FahrenheitToCelsius xmlns="http://www.w3schools.com/xml/">
<Fahrenheit>100</Fahrenheit>
</FahrenheitToCelsius>
</soap12:Body>
</soap12:Envelope>
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx",
<options xmlns="xdmp:http">
<format xmlns="xdmp:document-get">xml</format>
<headers>
<Content-Type>application/soap+xml; charset=utf-8</Content-Type>
</headers>
</options>,
$envelop
)
HTTP POST:
let $body := text {
string-join(
("Fahrenheit=" || encode-for-uri(string(100))),
"&"
)
}
return
xdmp:http-post(
"http://www.w3schools.com/xml/tempconvert.asmx/FahrenheitToCelsius",
<options xmlns="xdmp:http">
<headers>
<Content-Type>application/x-www-form-urlencoded</Content-Type>
</headers>
</options>,
$body
)
HTH!