开发者

Server name in XML response message?

I'm currently developing a set of webservices in Java, to host o开发者_如何学Cn Axis2 running over WebLogic 10.3.0. These webservices receive and return SOAP messages.

As I have a clustered environment on WebLogic, I would like to have the WebLogic's server name (the one I configured using the Administration Console) returned in the response message body. Is there any way I can do this programmatically or by configuration on the Administration Console?

Thanks in advance for your help solving this out!


You can get the name of the server via localhost like this:

String hostname = InetAddress.getLocalHost().getHostName();

Update

The above returns the name of the server it runs in, so it would give the name of the webservice host.

If you need the name of the server in front of the webservice, you can get that from the request:

String hostname = request.getRemoteHost();

should do the trick. Beware that the remote hostname is what the socket client used to set up the connection, this need not be the DNS name. If you need the DNS name, you can use:

String hostname = InetAddress.getByName(request.getRemoteAddr()).getHostName();

Update 2

If what you mean is not related to the server (solution 1) or a forwarding proxy (solution 2) but a kind of logical cluster name, you could define that in your web.xml as context parameter:

<context-param>
    <param-name>clustername</param-name>
    <param-value>OurPrettyCluster</param-value>
</context-param>

and read that in your servlet:

ServletContext context = getServletContext();
String clustername = context.getInitParameter("clustername");

If this is also not helping, you need to update your question and describe your cluster configuration because with the information given not much more can be done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜