Endpoint Query String


I’m trying to setup a endpoint rule for a wsdl. It is called as https://domain.com/abc/1.0?wsdl

I’ve tried most regex for path, but I cannot seem to match the ?wsdl side.

Is there regex I am messing for this? (or will I have to muster something up in the middleware?)


The path will only match on the path, not query Params.

What is it you need to do after it gets matched, there is a way to match on query params but it’s only useful in certain cases?


I was hoping that https:/domain.com/abc/1.0 would be the bound endpoint for services and https:/domain.com/abc/1.0?wsdl would be the wsdl defining the service. (This is our pre-tyk setup)

The wsdl is generated w/ a binding endpoint to match the host passed in. But with tyk in between the host becomes something like backendapi.domain.com I was hoping to rewrite the xml back the caller.


Ah, that is tricky. Tyk matches on the path only, not params, so to differentiate that endpoint you would need to integrate it into the path.

I assume the wsdl one is a different upstream endpoint altogether?


No, the wsdl one is not a diff upstream/backend. Same endpoint


Right, I think this might not be possible at the moment, matching is done on the path, not on path+params, so this would need to be part of an update down the line.


so we should open a github issue?


I’d suggest adding it to this issue here, as it is related and already milestoned:


There might be a workaround here, it involves redirects and virtual endpoints:

1. Have some PRE middleware that detects the wsdl parameter:

var helloWorld = new TykJS.TykMiddleware.NewMiddleware({});
log("------------ Initialising PRE middleware ------------");
helloWorld.NewProcessRequest(function(request, session, config) {
    log("Running sample  PRE PROCESSOR JSVM middleware with iteration")
    if (request.Params.hasOwnProperty("wsdl")) {
        log("WSDL Detected!")
        request.URL = "/reserved/wsdl/getter"
        request.AddParams["wsdl"] = "123"
    return helloWorld.ReturnData(request, {});

// Ensure init with a post-declaration log message
log("------------ Sample PRE middleware initialised ------------");

The above will only change our path variable if we detect the wsdl paramter, we then change the URL (path) of the request, and also - for the sake of it, add the wsdl param back.

2. Create a virtual endpoint that fetches the WSDL, and modifies the XML in some way to return to the end user:

function getXML (request, session, config) {
        log("XML Test running")
        var newRequest = {
            "Method": "GET",
            "Body": "",
            "Headers": {},
            "Domain": "http://httpbin.org",
            "Resource": "/get",
            "FormData": {"wsdl": "my-custom-param", "foo":"bar"}

        var resp = TykMakeHttpRequest(JSON.stringify(newRequest))

        log("Got resp")
        var cleanResp = JSON.parse(resp)

        var responseObject = {
            Body: cleanResp.Body,
            Code: cleanResp.Code

        return TykJsResponse(responseObject, session.meta_data)   
log("---------> getXML initialised")

(edit: The Form Data does not seem to be working properly, we’ll need to investigate why that is).

The above function just makes a request to /get on httpbin and pushes the response back to the user. But the principle is the same.

So essentially:

  • Pre Middleware detects the ?wsdl querystring, if it detects it, it redirects the request to a reserved virtual path
  • The virtual path then handles fetching the actual WSDL and transforms it as needed for the end user.

Middleware response