如何在 JBoss 7 java web 服务中更改soap 地址

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11527931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 05:27:00  来源:igfitidea点击:

How can I change soap address in a JBoss 7 java webservice

javajax-wsjboss7.x

提问by j2gl

How can I change the soap address in a web service. I'm working on JBoss 7.1.1.

如何更改 Web 服务中的soap 地址。我正在研究 JBoss 7.1.1。

I have this web service class:

我有这个网络服务类:

@WebService
public class Card {

   @WebMethod
   public CardResponseDTO insertCard(
           @WebParam(name = "cardRequestCardDTO") CardDTO cardDTO,
           @WebParam(name = "userName") String userName) {

       Date today;
       CardResponseDTO cardResponseDTO = new CardResponseDTO();

       try {
            today = Calendar.getInstance().getTime();
            // My logic in here...
            return cardResponseDTO;
       } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            cardResponseDTO.setErrorCode(-2);
            cardResponseDTO.setErrorMessage(ex.getMessage());
            return cardResponseDTO;
       }
   }
}

And when I'm working at my localhost works fine with this WSDL:

当我在我的本地主机上工作时,这个 WSDL 工作正常:

<wsdl:service name="CardService">
  <wsdl:port binding="tns:CardServiceSoapBinding" name="CardPort">
    <soap:address location="http://localhost:8080/inventory-ws/Card"/>
  </wsdl:port>
</wsdl:service>

But when I deploy to my server, that has a name server1.somedomain.com, doesn't work because I got just http:// server1:8080/ ...

但是当我部署到我的服务器时,它有一个名称 server1.somedomain.com,不起作用,因为我只有 http:// server1:8080/ ...

<wsdl:service name="CardService">
  <wsdl:port binding="tns:CardServiceSoapBinding" name="CardPort">
     <soap:address location="http://server1:8080/inventory-ws/Card"/>
  </wsdl:port>
</wsdl:service>

What I need is how to make it work in my server with the complete url: server1.domedomain.com.

我需要的是如何让它在我的服务器中使用完整的 url:server1.domedomain.com。

Thanks in advance.

提前致谢。

采纳答案by ppapapetrou

You have to configure jboss to listen to the interface you want. To do so you have to edit the standalone.xml file and add some new interface tags. I think this post might be useful. https://community.jboss.org/message/614897

你必须配置 jboss 来监听你想要的接口。为此,您必须编辑 standalone.xml 文件并添加一些新的界面标签。我认为这篇文章可能有用。 https://community.jboss.org/message/614897

回答by Timm

If you need to deploy SOAP web services for public access e.g. via Apache you can remove in the standalone.xmlthis line: <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>at all.
Then the host name will be taken over from the WSDL URL.
In this case you do not need to change the configuration for every deployment stage. For example dev.myhost.com, qa.myhost.com or ww.myhost.com.

如果您需要为公共访问部署 SOAP Web 服务,例如通过 Apache,您可以在standalone.xml 中删除这一行:<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>at all。
然后主机名将从 WSDL URL 中接管。
在这种情况下,您不需要为每个部署阶段更改配置。例如dev.myhost.com、qa.myhost.com 或 ww.myhost.com。

This avoids also the problem with wrong SSL port 8443 for public services.

这也避免了公共服务的 SSL 端口 8443 错误的问题。

回答by Olivier Masseau

To clarify,

澄清,

In the standalone.xml, just under the tag:

在standalone.xml中,就在标签下:

<subsystem xmlns="urn:jboss:domain:webservices:1.1">

You must modify these entries

您必须修改这些条目

<modify-wsdl-address>true</modify-wsdl-address>
<wsdl-host>www.myhost.com</wsdl-host>

To change port:

更改端口:

<wsdl-port>80</wsdl-port> <!-- case you need change port, instead 8080 -->
<wsdl-secure-port>443</wsdl-secure-port> <!-- case you need change port, instead 8443 -->

To change URI Schema:

要更改 URI 架构:

<wsdl-uri-scheme>https</wsdl-uri-scheme> <!-- or http for non secure -->