0

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!

Community
  • 1
  • 1

1 Answers1

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>
HM.Rajjaz
  • 369
  • 1
  • 3
  • 17
  • Thanks, adding + before the property name solved it, but I don't understand why and what adding + sign means or does. If you know this, please share :) – Plain Ol' Human Jun 02 '16 at 10:42
  • Also, it still doesn't work if I try this approach (adding +) with defined endpoints or if I use local entries instead of properties, which is a shame. Do you have any idea how these two options could be achieved/fixed? – Plain Ol' Human Jun 02 '16 at 10:53
  • use the + to control encoding as this is part of the URI Template specification. Is the issue you've run into double encoding an already encoded value? In that case you can update any HTTP Endpoint variables you don't want encoded with a + (e.g:{+uri.var.alreadyEncoded}). – HM.Rajjaz Jun 03 '16 at 04:20