Plain Ol' Human
Plain Ol' Human

Reputation: 45

WSO2ESB HTTP Endpoint throws exception when using uri.var parameters in the uri-template

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!

Upvotes: 0

Views: 863

Answers (1)

HM.Rajjaz
HM.Rajjaz

Reputation: 389

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>

Upvotes: 1

Related Questions