Getting Client IP from webMethods Designer?

Hello. I’d like to know how to get a Client IP from the webMethods Designer. Here’s what the scenario is like:

  1. The target is to get the IP Address of the Client if they look at their ipconfig, in particular the IPv4 address.
  2. I know there are some topics that deal with this, like this : How to get client IP address in webMethods service But when I tried that, it gives out different IP, like 127.0.0.1, I don’t think this is the one I’m looking for. (When I tried it with different computer and using Postman, it gave out something like 10.94.72.16, so I don’t think this was a Client IP example.

Help will be appreciated when it comes to getting the Client IP from Designer. Thanks!

When you say “Designer”, do you mean that you want your service to be able to get the IP address of the calling client at “runtime” ?

For reference the linked suggestions can be replaced with a simple service invoke to

pub.flow:getTransportInfo

However, remember that the client can choose to spoof the IP address or hide it completely so you cannot rely on it always being accurate and instead only use it for guidance.

regards,
John.

@John_Carter4 So which part of the ipInfo from that function should we refer to for the Client IP? The localIp or remoteIp?

I’ve also heard from some sources about the thing called ‘X-Real-IP’. How do we access that in either the Designer/MSR or API-Gateway?

You would want to reference the remote IP, local would be the IP address of the server on which webMethods is running. The X-Real-IP is populated used in relation to an ingress/proxy product that sits is positioned in front of webMethods. The remote IP would always be the IP address of this product, hence most of these type of products will forward the original IP address in a different HEADER attribute such as the one mentioned. Unfortunately there is no standard for this, so it could change from product to product.

These additional attributes would show up in the section headers.
John.

@John_Carter4 I noticed that the one I’m looking for from that service is /transport/http/requestHdrs/x-forwarded-for. However, x-forwarded-for doesn’t always appear, and so I can’t just grab the x-forwarded-for. How do you suppose I get around that, create a custom document?

You don’t need to create an explicit document type, you can just map requestHeaders to a document in pipeline out named headers.

Then add a branch condition to act on the new attribute i.e. set the SWITCH property to ‘/headers/x-forwarded-for’.
add two sequences, one labelled $null and the other $default.

In the $default sequence add a map step, and then explicitly map ‘/headers/x-forwarded-for’ to clientIP. You will need to add the ‘x-forwarded-for’ attribute into the headers document as it is not typed. To do this right click on the headers document attribute in the ‘pipeline in’ section of your map step and select insert → string. Then name it ‘x-forwarded-for’, don’t forget to map it to clientIP before saving or changing view. Designer automatically cleans up any attributes which are not explicitly used!

I would have normally added some screenshots, but tech community is blocking uploads at the moment, maybe related to log4j heightened security.
regards,
John.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.