问题
I tried to invoke a REST endpoint by using the following configuration:
...
<property name="uri.var.host" value="localhost:8080"/>
<property name="uri.var.context" value="my-service"/>
<call>
<endpoint>
<http method="POST" uri-template="http://{uri.var.host}/{uri.var.context}" />
</endpoint>
</call>
...
But then I get an XMLStreamException that says "DOCTYPE is not allowed":
[2016-06-01 17:16:15,702] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
...
On the other hand, it works without any issues if I don't use uri.var parameters, i.e. this configuration works:
...
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:8080/my-service"/>
</endpoint>
</call>
...
Unfortunately, I need to use uri.var parameters since the target endpoint needs to be specified dynamically. So the question is how can I make uri.var parameters to work? Thanks!
回答1:
If you enable the wirelog you can find what is the actual endpoint you are referring.see below sample request.
<property name="uri.var.username" expression="$func:username"/>
<call>
<endpoint>
<http method="get" uri-template="{+uri.var.apiUrl}/users/{+uri.var.username}/orgs"/>
</endpoint>
</call>
来源:https://stackoverflow.com/questions/37573193/wso2esb-http-endpoint-throws-exception-when-using-uri-var-parameters-in-the-uri