配置在WebSphere Liberty服务器中使用同一个WAR文件的两个上下文根。

huangapple go评论74阅读模式
英文:

Configure two context-root same war file in Webpshere Liberty server

问题

以下是翻译好的内容:

从ANT(EAR)迁移应用程序到Maven(WAR)。在ANT项目中,WAR中有WEB层,JAR中有EJB层。EJB模块具有WebService代码。现在我正在从ANT迁移到Maven,因此应用程序将只有WAR。在ANT中,我可以拥有两个不同的上下文根,如“/webapp”和“/webservice”。上下文根“/webservice”在EJB JAR归档中定义,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<webservices-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
		xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd" 
		version="1.0">
	<!-- 可选的HTTP发布模块覆盖 -->
	<http-publishing context-root="/webservice" />
</webservices-bnd>

因此,我有不同的URL来访问WEB和WebService,
http://localhost:9080/webapp/application/index.html - Webapp
http://localhost:9080/webservice/service/helloworld?wsdl - Webservice

根据IBM文档 https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_jaxws_binding.html

<http-publishing context-root="/webservice" />中的context-root在只有WAR文件的情况下不起作用。因此,我只能使用相同的“webapp”上下文根访问webapp和webservice。
但是,我需要两个不同的URL来访问webapp和webservice,就像上面的示例一样。我该如何实现这一点呢?

英文:

Am migrating application from ANT (EAR) to Maven (WAR). In ANT project I have WEB layer in WAR and EJB layer in JAR. EJB module has WebService code. Now am migrating ANT to Maven Henceforth application will have only WAR. When application in ANT I can have the two different context-root like "/webapp" and "/webservice". The context-root "/webservice" defined in EJB JAR archive like below,

&lt;webservices-bnd xmlns=&quot;http://websphere.ibm.com/xml/ns/javaee&quot; 
		xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
		xsi:schemaLocation=&quot;http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd&quot; 
		version=&quot;1.0&quot;&gt;
	&lt;!-- optional http publishing module overrides --&gt;
	&lt;http-publishing context-root=&quot;/webservice&quot; /&gt;
&lt;/webservices-bnd&gt;

So I have different URL to access WEB and WebService,
http://localhost:9080/webapp/application/index.html - Webapp
http://localhost:9080/webservice/service/helloworld?wsdl - Webservice

As per IBM documentation https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_jaxws_binding.html

context-root in &lt;http-publishing context-root=&quot;/webservice&quot; /&gt; will not work when I have only WAR file. So, I can only access webapp and webservice using same "webapp" context-root.
But I need two different URL to access webapp and webservice like above. How can I achieve this.?

答案1

得分: 1

如果您将您的EAR文件合并为单个WAR文件,那么就无法覆盖该WAR文件中不同端点的默认上下文根。

您可以使用Liberty的ibm-ws-bnd.xml配置文件覆盖EJB jar的默认上下文根,结合您提到的<http-publishing context-root="/webservice" />元素。您需要将包含EJB Web Service jar的EAR文件与您的WAR文件分开打包。

英文:

If you're combining your EAR file into a single war, then there is no way override the default context-root of different endpoints in that war.

You can override the default context-root for an EJB jar using Liberty's ibm-ws-bnd.xml configuration file, along with the element that you mentioned: &lt;http-publishing context-root=&quot;/webservice&quot; /&gt;. You'd need to keep your EAR file with the EJB Web Service jar packaged separately from your war.

huangapple
  • 本文由 发表于 2020年10月22日 23:24:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/64485489.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定