- たとえば、速度テンプレートを使用して、ebxml SOAP メッセージを手動で作成できます。
テンプレートの例:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ser="http://test/Service">
<soap:Header/>
<soap:Body>
<ser:insertRequest>
<ser:routingHeader>
<ser:operationType>${headers.OPERATION_TYPE}</ser:operationType>
<ser:messageId>${exchange.properties.messageId}</ser:messageId>
<ser:sourceId>${exchange.properties.sourceId}</ser:sourceId>
<ser:destinationId>${exchange.properties.destinationId}</ser:destinationId>
</ser:routingHeader>
<ser:datagram>
${body}
</ser:datagram>
</ser:insertRequest>
</soap:Body>
</soap:Envelope>
http、http4またはjettyコンポーネントを使用して、このような ebXml SOAP メッセージを apache camel 経由で送信できます。
to("jetty:http://{{server.host}}:{{server.http.port}}/service/").
log(LoggingLevel.INFO, "HTTP response code: ${in.header.CamelHttpResponseCode}")
SOAP応答を手動で解析するだけでよい場合(XPathなど)、またはXSLTで応答を変換できます。XML を POJO に変換するには、beanio、xstream、jaxb などを使用できます。
....
to("velocity:file:///{{karaf.home}}/etc/vm/ws-message-oc.vm?contentCache=true")。
setProperty(Exchange.CONTENT_TYPE).constant("アプリケーション/soap+xml")。
setProperty(Exchange.CONTENT_ENCODING).constant("gzip").
setProperty(Exchange.CHARSET_NAME).constant("utf-8")。
//log(LoggingLevel.INFO, "WS リクエスト: ${body}").
to("jetty:http://{{app-server.host}}:{{app-server.http.port}}/service/")。
log(LoggingLevel.INFO, "HTTP 応答コード: ${in.header.CamelHttpResponseCode}")
//log(LoggingLevel.INFO, "WS 応答: ${body}")
.setHeader("callRC").xpath("//ser:callRC/text()", String.class, XmlNamespaces.NAMESPACES.getNamespace())
....