-->

WebSphere: change port of web service from default

2019-09-09 20:09发布

问题:

I've created a web service using this example:

http://www.albeesonline.com/blog/2008/07/27/creating-a-webservice-using-rad-7/

When I call the web service to get the WSDL, I use a URL like this:

http://acme.com/storefront/services/InventoryInquiry?wsdl

And WebSphere responds with a WSDL page with a URL like this:

http://acme.com:9082/storefront/services/InventoryInquiry/wsdl/InventoryInquiry.wsdl

What I'd like is for WebSphere to respond using SSL and port 443, and not the WebSphere default host port.

I tried modifying the "Provide HTTP endpoint URL information" page in WebSphere console for the application to use "https://acme.com:443" for the "HTTP URL prefix", but WebSphere doesn't use this, even after restarting WebSphere.

How do I configure WebSphere so that it doesn't use its default ports when responding to web service requests?

I'm using WebSphere 6.1.

Some background information:

The service is included in a J2EE application that uses Struts for its design pattern. The struts-config.xml is configured to serve the app on ports 80 and 443. The WAS server where the app runs is fronted by an Apache web server, which is redirecting requests to the app via a load balancer.

The AWS load balander config is directing requests among four separate WAS servers, each serving a copy of the application. Each WAS server is configured to deliver a unique server ID string back to the user. AWS uses this string to determine which WAS server will handle subsequent requests made by the user. This all works fine for the parts of the J2EE app that are handled by Struts, but the web service exists outside of that context. This seems to be why the web service responds using the WAS default secure port, and not the port defined in Struts.

I can't change the WAS default secure port to 443, because I can't have two instances of WAS on the same server both listening to port 443.

回答1:

In general you have two choices:
1. You can install IBM Http Server (IHS) and WebSphere Plugin to route requests to WebSphere. IHS uses by default 80 and 443 ports.
2. Change default SSL port in WebSphere - In Server > Ports change the WC_defaulthost_secure from 944x to 443.

There is second issue in your question - do you want to protect using SSL whole service or just WSDL?
To configure it you will either need to define security constraints to protect selected URIs or configure HTTP server to only allow SSL access to the service.

UPDATE
If you have Apache Web server in front, then install and configure WebSphere Plugin (if you currently use mod_proxy or something else). WebSphere Plugin is available for Apache and will do dispatching and load balancing across multiple WAS instances (if they are clustered then you can generate plugin automatically from Deployment Manager, if you have many standalone instances - you will need to merge plugin, there is a tool for that).
It doesn't matter that your app is using Struts, your wsdl can still be served via Http server and plugin.
For redirection to HTTPS you need to solve that issue from your other post - security-constraint in web.xml is not enforced as I assume it is the same environment.