不使用 wso2 ESB REST 发送 SOAP 消息 API
SOAP messages are not sent using wso2 ESB REST API
我正在尝试使用 wso2 ESB 将 SOAP 后端公开为 REST API。我正在使用 payload factory 发送 soap body 消息,但它不起作用。
这是我在 wso2 esb 代码中的 API 资源:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/akademik" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/students?symbol={symbol}">
<inSequence>
<log level="custom">
<property expression="$url:symbol" name="symbol"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:sem="http://semogabisa.te.net/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sem:sayHi>
<arg0></arg0>
</sem:sayHi>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$url:symbol"/>
</args>
</payloadFactory>
<header scope="default">
<m:complexHeader xmlns:m="http://org.synapse.example">
<m:property key="Content-Type" value="application/xml"/>
</m:complexHeader>
</header>
<send>
<endpoint>
<address format="soap11" uri="http://localhost:8084/HelloWorld"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
Soap 消息未发送到后端 Web 服务,它表示为空。
我已经使用具有相同 soap 信封格式的 SOAPUI 测试了后端服务并且它正在工作
我认为你在 header 调解器上犯了一些错误。 "HelloWorld" 根据您的 SOAP UI 请求,后端服务不需要 SOAP header。所以删除 header 调解器。
Select Synapse if you want to manipulate SOAP headers. Select Transport if you want to manipulate HTTP headers.
后端似乎是 SOAP11,SOAP11 类型是 "text/xml"。您可能需要设置此 属性.
<property name="messageType" value="text/xml" scope="axis2"/>
当您从 ESB 发送消息时,您需要设置 属性 "messageType",然后 ESB 将格式化匹配后端所需的消息。
如果您发现 ESB 在向后端发送消息时将一些上下文附加到您的后端 URI,您可能需要这个 属性。
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
好贴士:
请打开您的 "synapse.transport.http.wire" 作为 DEBUG,这将输出进出 ESB 的每条消息。此日志将包括 HTTP header 和 body。在你得到 wire log 之后,你可以将 wire log 与你的 SOAPUI 请求进行比较,然后找出哪一部分是错误的。
https://docs.wso2.com/display/ESB481/Setting+Up+Logging
我正在尝试使用 wso2 ESB 将 SOAP 后端公开为 REST API。我正在使用 payload factory 发送 soap body 消息,但它不起作用。
这是我在 wso2 esb 代码中的 API 资源:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/akademik" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/students?symbol={symbol}">
<inSequence>
<log level="custom">
<property expression="$url:symbol" name="symbol"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:sem="http://semogabisa.te.net/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sem:sayHi>
<arg0></arg0>
</sem:sayHi>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$url:symbol"/>
</args>
</payloadFactory>
<header scope="default">
<m:complexHeader xmlns:m="http://org.synapse.example">
<m:property key="Content-Type" value="application/xml"/>
</m:complexHeader>
</header>
<send>
<endpoint>
<address format="soap11" uri="http://localhost:8084/HelloWorld"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
Soap 消息未发送到后端 Web 服务,它表示为空。
我已经使用具有相同 soap 信封格式的 SOAPUI 测试了后端服务并且它正在工作
我认为你在 header 调解器上犯了一些错误。 "HelloWorld" 根据您的 SOAP UI 请求,后端服务不需要 SOAP header。所以删除 header 调解器。
Select Synapse if you want to manipulate SOAP headers. Select Transport if you want to manipulate HTTP headers.
后端似乎是 SOAP11,SOAP11 类型是 "text/xml"。您可能需要设置此 属性.
<property name="messageType" value="text/xml" scope="axis2"/>
当您从 ESB 发送消息时,您需要设置 属性 "messageType",然后 ESB 将格式化匹配后端所需的消息。
如果您发现 ESB 在向后端发送消息时将一些上下文附加到您的后端 URI,您可能需要这个 属性。
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
好贴士:
请打开您的 "synapse.transport.http.wire" 作为 DEBUG,这将输出进出 ESB 的每条消息。此日志将包括 HTTP header 和 body。在你得到 wire log 之后,你可以将 wire log 与你的 SOAPUI 请求进行比较,然后找出哪一部分是错误的。
https://docs.wso2.com/display/ESB481/Setting+Up+Logging